Use instance cache and assorted refactorings

Chat me, I'm lazy!