Reorder factories.py for clarity. Rename a func