final fixes to permutedims