Minor fixes

* Put a limitation on the number of files to be in upload queue
* Defer the Close to http request after the oauth send happens: this
seems to solve the issue on my laptop (desktop computer didn't have the
issue)
* in case of upload failure, try to recover from it and treat current
file as invalid