Fixed bug where error message wouldn't be returned in json response.
Code cleanup.
Added user/pass parameters to uploadFile().