Additional tests and code cleanup.