Fix leaked global variables

I found these when auto analysing the code (see #1143).

You really should use jshint/jslint to do some quality checks on your codebase.

Have you considered porting to node.js and abandoning java? It seems all the javascript tools you need are out there for node.js - I have no idea how you are going to integrate with node.js tools. The project I work on wraps bladerunner in a grunt task and then uses it for the minimal amount it can - its great you can write plugins for bladerunner now, but it all has to be in java, making it useless to integrate with most javascript tools?. anyway, just a thought.