ADDED: check validity of permutation arrays before permute

Can be turned off when used internally.