fix js errors found by jshint