Clean up upload logic: issue #3.