Re-arrange stuff. fix minor bug in upload-loader.