Move main.js code into JSNI