Fix bugs in main.js