fix jshint errors and warnings

Just fixed annoying jshint errors. The code is a bit cleaner now.