Clean up and simplify implemenation of delete cache.