Cache logic fix