Final cleanup, docstrings, removed unused statements.