Cleanup javascript so it passes JSLint tests