Tidy code somewhat using JSLint