Modularity

The javascript should be modular which assists portability, configurability and hot-swapping.

This will also help issue #19.