Check with JSHint

This PR does a few things:

1. It fixes a number of problems detected by [jshint](http://www.jshint.com/), leading to additional clean-ups.
2. It adds a `jshint` build target to run jshint on the sourcecode.
3. It adds the `jshint` target to the `check` and `integration-test` targets, so that they become part of the integration test.

I'm reasonable sure that part (1) is desirable. What are people's thoughts on parts (2) and (3)?