Fixes permutation_linear_to_canonical and permutation_canonical_to_linear