Fix broken tests and code.