Switched to using weak canonicalisation and precomputed powers for performance
speedup.