Clean things up a bit, fix unit tests.