adding logging for debugging; cleaning up js per jshint