Fix a bug in caching