Add docstrings and style fixes