The regex helpers were converting strings to regex-tdfa regular expressions on the fly every time, but this appears to be quite expensive. The simplest memoisation lib seems to solve it nicely.