Restructured JS to be more modular. Refactored board.js.