Fix bugs in JavaScript files