Convert comments to docstrings + simplify code