Moved the factory routines into their own module