factory.py: small fixes; add new docstrings