Refactored to build cleanly for both jvm and js. Fixed various issues with the data model and the DSL.