Cleaning up some of the javascript