A lot of JavaScript code cleanup.