Initial checkin; code is complete (except for one TODO; see code), but the tests need a little more coverage.