Add collection factory, lots more refactoring in mapper