small optimizations, code refactoring; jshint fixes