Fixed JSLint errors and one runtime error