Several smaller bugfixes and performance updates for resources. Added a test that demonstrates how to create a custom dependency (and did some refactorings to make that easier).