Some bug fixes & jshint fix.