A few more bugfixes, cleanup. All tests running for now.