Also rearranges some functions for easier cleanup on failure.
Attach a file by drag & drop or click to upload