Cleanup and tests.
Support setting resource models in createResource.