Refactor cachetools package