Refine docstrings and fix style issues (flake8)