Reformat code and fix jslint errors