Cleaned up a lot of the javascript