Refactoring to support repositories and Unit of Work