Fixed small error.
Also fixed code that wasn't JSLint-compliant.