Bug fixes, removed cache, reformatting

There were a few bugs with shifting the unique values to the start of A and the end of B, which were masked by the heavy use of the cache; the cache has been temporarily removed to make it easier to adjust the underlying algorithm (sorting is now is 3x slower at the moment); and some of the functions were reformatted because the old code was apparently unreadable? I dunno, no one considers paragraphs to be obfuscated sentences.