Fix some JavaScript issues found by jshint