Cleaning up the code related to caching