Fixed bugs in application.js