Use instance cache and assorted refactorings