Rewriting the upload process to be safer

@hoganld can you review this and let me know? This will resolve #33