selfhealing code cleanup and make sure tests pass.