More jshint and misc fixes

Fixes "Uncaught ReferenceError: count is not defined"