Fix to cache-clearing code