Tweaked upload code