Fixes for the cache sometimes pulling the same item twice form the cache queue, racing condition and some other case.