cleanup of permutedims