Improved cache cleanup