Repository API refactoring and cleanup.