JSLint

If you're ok with JSLint, this fixes all but two issues. Some may be pedantic, but others I think improve the code (and being able to run JSLint without too many distractions can help catch future errors).