Optimized/cleaned up main.js