Some minor refactoring of the cache queue.