Full rewrite of api.js with main point of actually using Promises in a right way

First remove "timeouted promises", merge some of authorization.js into api.js and others part of it into main.js. Make api more straightforward. Add error reporting utilities printing stack trace.