improved documentation, also removed memory allocations from permutation.rank