Refactor CacheBuilder into smaller functions.