Fixed most errors thrown by jshint

Except for "Don't make functions within a loop"