Some more pep8 optimisations and add docstrings