Merge latest CommandT matching updates

See comments to the CommandT commits that adds memoization.

tldr: This adds a memoization which greatly improve performance
in some corner-cases, e.g. when searching for 'aaaaa' in
'aaaaaaaaaaaaaaaaaaa' string.
style improvements