Fixing recursion for cache clean up