Initial commit.  No tests yet, but the code is broken up, and written a lot better than it had been.