Breaking the JS into modular sections

Fixes #339.
Fixes #312.
v2.0.0-beta.6