Added jshint task to Gruntfile

I've also fixed several jshint errors and warnings.
There is an issue in the ``validateChanges`` function in ``core.js`` which should be fixed with the changes mentioned in #864
The commit seems much bigger than it actually is!