Initial commit of re-write of main.js