Fixing race conditions with clearing cache.