Cleanup and unit tests.