Make caching more robust