Fixed a multithreading issue with the cache