more caching, design refactoring