Big changes to js.
Moved functions from index.js to game.js