cleanup the code and fix jshint