Cleaned up the javascript and api