Some more refactoring around the factory.