Reformat, added upload error handling