Refactor

This pull request brings the codebase up to date with our current
coding style, including a current .jscsrc and .jshintrc. This
also switches to a prototypal method, rather than the revealing
module pattern. Some parts have been factored out into separate
files where appropriate.

The test suite is untouched and the refactored code passes all of
the existing tests.

This is the first stage in making some feature changes to schemata
as it makes the codebase easier to work with.

I have installed this version on AI and the test suite continues to pass.