Changed the interface of the weak canonicalisation code to avoid large scale
code duplication.