Merge "Use a TreeMap for PL patterns so that they are sorted and hashed properly." into main