added more constraints, improved some docstrings