Refactor repo code into RepositoryManager