Add docstrings.  Add extra sanity checks.