Put script in main.js and fix some UI stuff