Refactor Cache to use popitem