a lot of refactoring, some new classes, basic support for context creation