Cleaned up legacy code for caching