Some cleanups and tests.