permutations function rewritten.
Extracted multiply_lists to a separate function; far more readable and I think it might of fixed a bug. I also rewrote the section after so that the identity permutations keeps the non-rearranged.