Clean up JavaScript

Added comments and removed unnecessary JS.