In some cases, freeing the image cache keys would not update next/previous links - causing future updates to reference freed memory. Also assert the `last_key` is never points to freed memory.