Added locking, pushed the state to the CachedRepository.