Fixed jshint warnings and fixed some bugs that were introduced when fixing the jshing warnings...