Introduce AbstractRepository to get rid of some of the duplication.