Revert "Revert "Fix the computation of linear ordering.""

PS2 fixes the obvious typos/wrong refactoring.

This reverts commit e50fa5887b1342b845826197d81950e26753fc9c.

Change-Id: I22f81d63a12cf01aafd61535abc2399d936d49c2
4 files changed