Second try, changed upload to not use deprecated upload function. Also did cleanup.