Tests, cleanups, and fixes.