Moving closer to commonjs

Replaced vars with module.exports and export to window object for now.