Adds jshint and refactors some code