canonicalize in-place