Fix invalid iterator in Cache