Fix cache pruning