Started cleaning up some of the javascript code.