Fixed jshint issues, and cleaned up some of the code.