Docstring complete. Beginning of something useful. Now to fill in the hard parts.