fix crash when upload is aborted clientside (as reported by sqozz on irc); add lots of comments in api.js