Stop repository being a singleton and beginnings of factoring out code to base repository.
Factor out common code to BaseRepository
Complete refactoring to use a BaseRepository