Fixed bugs in upload