Naming the resources "type" was a stupid mistake, and is a huge source of confusion when also talking about real types. Fix this before it gets out of hand.
This adds state caching to avoid repeated execution when not necessary.