More code changes and unit tests.