Cleaned up code.

Now javascript is a bit more optimized and has no global variables.
steady
merged pull request from shash7
finishing merge from shash
merge merge merge