clean-up and some docstrings