Bug fixes on permutation_mediation