Cleaned up code, fixed error message in upload