Refactoring

Moved layout and modules code to layout.js.
No longer need to call writer.init().