Tidy up some things. Add some missing docstrings