Simplifed vars and main.js now a function.