If we have (x,y), (y,z), etc, we need to have (x,z) as the solution instead, and sometimes this didn't happen. Fixes #1627