resource creation and a lot more

resource creation, lazy loading of parents, parent type checking, some
more refactoring, and a bunch of unit tests.