Added some comments for clarification. Haven't resolved problem with transpositions going out of range, but interaction with iterating code is unclear, so will merge back into master and work on iteration first: that is more important because any hack that fixes the out-of-range issue should be compatible with iteration.