Fix JSHINT errors

These changes also pass JSLINT. Fixes build errors reported by travis-ci, see #2654.