Bug fixes to correctly flush out the right cache entries to avoid corruption