Lots of code cleanup driven by jshint