add a bunch of docstrings etc