Refactor OnMemoryRepositories.