Add documentation.

Also fix up any small formatting tweaks.