Repository related changes and refactoring