Refactoring and caching