If we want that this core algorithm stays maintainable we should add at least documentation for the three main entrypoints scanA, scanB and match. I know they are not public ... but I had a hard time understanding