Refactor use of caching and storage functions