Code cleanup, pep8 fixes, docstrings edits

- Code cleanup with flake8 for pep8 fixes in new code
- Edits to docstrings
- Fixed doc tests