Address @alex's comments:

* Fix docstring formatting
* Use divmod for a speedup
* Cleanup 2-spacing
* Remove unused variables