Add lots of comments and fix most jslint errors