Add docstrings and fix PEP8