But it and the rest of the code are greatly simplified. All correctness tests pass, many others don't.