fixing bugs in cache