Reduced the number of permutations of mapping by not generating cases where mapping[-1] != x
While earlier the number of terms or components of a function being permuted were (say) n after these changes they have reduced to n-1, thus i$

passed the tuple variable across functions instead of storing it on function