Rewrite

A complete rewrite, to make things more testable. Still a few dozen tests to be written, but there are over a hundred, now, and there used to be 0. So that's nice.

Some minor additional functionality came along for the ride, too.