Refactor repositories