factory.py: add more docstrings