Fix bugs related to caches