Fix two bugs concerned with duplicate named patterns.