cleaned up upload code

much more code reuse