Cleaned up the JavaScript