Tidy up of indexing functions, taken permutation madness out of the equation