Core/Phases: Use a O(n) operation when comparing phases instead of a O(n^2) one