Use permute pkg

Closes most of the issues (but not all) raised in #31: this issue discusses details and remaining issues. There really are some remaining issues, but the branch was growing too big: it is now 20 commits long and changes 33 files.
Yep, I was thinking about this. I only retained the tests that already were there: no test was removed, no new test was added. I was thinking this is something for 2.2-1.