Add support for resources by name

This is quite a large PR. Please use as a basis for discussion.
What was this line for?