Cache refactor