Removed debug code and fixed unit tests.