One bugfix, style changes, abstraction, and docstring additions