Fix some global leaks and satisfy jshint.

What do you think of this?

Best Regards
Philipp