Fixes upload logic bugs.