Cleaned up most of the javascript