Cleaned up code.

Now javascript is a bit more optimized and has no global variables.