Fixed permute vector

Split permute vector into three different files and fixed an error in
the bounds checking.