Document and reorder the code we already have, in preparation for a refactor. Also rename a few functions; no substantive changes.