Improved cache handling