jshint, styling, minor refactoring