Refactored the factories.