anchor.diff:      end;
      end;
     end;
  - end;
  -
  - if UnanchoredStart then begin
  -  StartInstruction:=Instance.UnanchoredStartInstruction;
  -  inc(Start,sskUnanchored);
  - end else begin
  -  StartInstruction:=Instance.AnchoredStartInstruction;
  -  inc(Start,sskAnchored);
  +
  +  if UnanchoredStart then begin
  +   StartInstruction:=Instance.UnanchoredStartInstruction;
  +   inc(Start,sskUnanchored);
  +  end else begin
  +   StartInstruction:=Instance.AnchoredStartInstruction;
  +   inc(Start,sskAnchored);
  +  end;
  +
    end;
   
    StartState:=@StartStates[Start];
    if assigned(StartState^) then begin
  -  State:=StartState^;
  +  result:=StartState^;
    end else begin
     WorkQueues[0].Clear;
     AddToWorkQueue(WorkQueues[0],StartInstruction,Flags);
  -  State:=WorkQueueToCachedState(WorkQueues[0],Flags);
  -  StartState^:=State;
  - end;
  -
  - for Position:=StartPosition to UntilExcludingPosition{-1} do begin // No -1 because match can be delayed of one byte
  -  LastState:=State;
  -  if Position<LocalInputLength then begin
  -   CurrentChar:=byte(ansichar(LocalInput[Position]));
  +  result:=WorkQueueToCachedState(WorkQueues[0],Flags);
  +  StartState^:=result;
  + end;
  +
  +end;
  +
  +function TFLREDFA.SearchMatch(const StartPosition,UntilExcludingPosition:longint;out MatchEnd:longint;const UnanchoredStart:boolean):longint;
  +var Position,LocalInputLength,Direction:longint;
  +    State,LastState:PFLREDFAState;
  +    LocalInput:pansichar;
  +    Flags,CurrentChar:longword;
  +    LocalByteMap:PFLREDFAByteMap;
  +begin
  +
  + if DoFastDFA then begin
  +
  +  if Reversed then begin
  +   result:=SearchMatchFastReversed(StartPosition,UntilExcludingPosition,MatchEnd);
     end else begin
  -   CurrentChar:=256;
  -  end;
  -  State:=State^.NextStates[LocalByteMap[CurrentChar]];
  -  if not assigned(State) then begin
  -   State:=RunStateOnByte(LastState,Position,CurrentChar,false);
  +   result:=SearchMatchFast(StartPosition,UntilExcludingPosition,MatchEnd,UnanchoredStart);
  +  end;
  +
  + end else begin
  +
  +  result:=DFAFail;
  +
  +  State:=InitializeStartState(StartPosition,UnanchoredStart);
  +
  +  LocalInput:=ThreadLocalStorageInstance.Input;
  +  LocalInputLength:=ThreadLocalStorageInstance.InputLength;
  +
  +  LocalByteMap:=@ByteMap;
  +
  +  if Reversed then begin
  +
  +   for Position:=StartPosition downto UntilExcludingPosition do begin
  +    CurrentChar:=byte(ansichar(LocalInput[Position]));
  +    LastState:=State;
  +    State:=State^.NextStates[LocalByteMap^[CurrentChar]];
  +    if not assigned(State) then begin
  +     State:=RunStateOnByte(LastState,Position,CurrentChar);
  +     if not assigned(State) then begin
  +      result:=DFAError;
  +      exit;
  +     end;
  +    end;
  +    if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
  +     if (State^.Flags and sfDFADead)<>0 then begin
  +      if result<>DFAMatch then begin
  +       result:=DFAFail;
  +      end;
  +      exit;
  +     end;
  +     if (State^.Flags and sfDFAFullMatch)<>0 then begin
  +      MatchEnd:=UntilExcludingPosition-1;
  +      result:=DFAMatch;
  +      exit;
  +     end;
  +     if (State^.Flags and sfDFAMatchWins)<>0 then begin
  +      MatchEnd:=Position+1;
  +      result:=DFAMatch;
  +     end;
  +    end;
  +   end;
  +
  +   Position:=UntilExcludingPosition-1;
  +
  +   if (Position>=0) and (Position<LocalInputLength) then begin
  +    CurrentChar:=byte(ansichar(LocalInput[Position]));
  +   end else begin
  +    CurrentChar:=256;
  +   end;
  +
  +   LastState:=State;
  +   State:=State^.NextStates[LocalByteMap^[CurrentChar]];
      if not assigned(State) then begin
  -    result:=DFAError;
  -    exit;
  -   end;
  -  end;
  -  if (State^.Flags and (sfDFAMatchWins or sfDFADead))<>0 then begin
  -   if (State^.Flags and sfDFADead)<>0 then begin
  -    if result<>DFAMatch then begin
  -     result:=DFAFail;
  -    end;
  -    exit;
  -   end;
  -   if (State^.Flags and sfDFAMatchWins)<>0 then begin
  -    MatchEnd:=Position-1;
  -    result:=DFAMatch;
  -   end;
  -  end;
  - end;
  -
  -end;
  -
  -function TFLREDFA.SearchMatchFullReversed(const StartPosition,UntilIncludingPosition:longint;out MatchBegin:longint):longint;
  -var Position,Start,NextPosition,LocalInputLength:longint;
  -    State,LastState:PFLREDFAState;
  -    StartState:PPFLREDFAState;
  -    StartInstruction:PFLREInstruction;
  -    LocalInput:pansichar;
  -    Flags,NextChar,CurrentChar:longword;
  -begin
  - result:=DFAFail;
  - LocalInput:=ThreadLocalStorageInstance.Input;
  - LocalInputLength:=ThreadLocalStorageInstance.InputLength;
  -
  - begin
  -  if StartPosition=(ThreadLocalStorageInstance.InputLength-1) then begin
  -   Start:=sskBeginText;
  -   Flags:=sfEmptyBeginText or sfEmptyBeginLine;
  +    State:=RunStateOnByte(LastState,Position,CurrentChar);
  +    if not assigned(State) then begin
  +     result:=DFAError;
  +     exit;
  +    end;
  +   end;
  +   if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
  +    if (State^.Flags and sfDFADead)<>0 then begin
  +     if result<>DFAMatch then begin
  +      result:=DFAFail;
  +     end;
  +     exit;
  +    end;
  +    if (State^.Flags and sfDFAFullMatch)<>0 then begin
  +     MatchEnd:=UntilExcludingPosition;
  +     result:=DFAMatch;
  +     exit;
  +    end;
  +    if (State^.Flags and sfDFAMatchWins)<>0 then begin
  +     MatchEnd:=Position+1;
  +     result:=DFAMatch;
  +    end;
  +   end;
  +
     end else begin
  -   if (rfUTF8 in Instance.Flags) and ((byte(ansichar(LocalInput[StartPosition])) and $80)<>0) then begin
  -    NextPosition:=StartPosition;
  -    UTF8PtrSafeInc(LocalInput,LocalInputLength,NextPosition);
  -    if (NextPosition>=0) and (NextPosition<ThreadLocalStorageInstance.InputLength) then begin
  -     NextChar:=UTF8PtrCodeUnitGetCharFallback(LocalInput,ThreadLocalStorageInstance.InputLength,NextPosition);
  -    end else begin
  -     NextChar:=$ffffffff;
  -    end;
  +
  +   for Position:=StartPosition to UntilExcludingPosition-1 do begin
  +    CurrentChar:=byte(ansichar(LocalInput[Position]));
  +    LastState:=State;
  +    State:=State^.NextStates[LocalByteMap^[CurrentChar]];
  +    if not assigned(State) then begin
  +     State:=RunStateOnByte(LastState,Position,CurrentChar);
  +     if not assigned(State) then begin
  +      result:=DFAError;
  +      exit;
  +     end;
  +    end;
  +    if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
  +     if (State^.Flags and sfDFADead)<>0 then begin
  +      if result<>DFAMatch then begin
  +       result:=DFAFail;
  +      end;
  +      exit;
  +     end;
  +     if (State^.Flags and sfDFAFullMatch)<>0 then begin
  +      MatchEnd:=UntilExcludingPosition-1;
  +      result:=DFAMatch;
  +      exit;
  +     end;
  +     if (State^.Flags and sfDFAMatchWins)<>0 then begin
  +      MatchEnd:=Position-1;
  +      result:=DFAMatch;
  +     end;
  +    end;
  +   end;
  +
  +   Position:=UntilExcludingPosition;
  +
  +   if (Position>=0) and (Position<LocalInputLength) then begin
  +    CurrentChar:=byte(ansichar(LocalInput[Position]));
      end else begin
  -    NextChar:=byte(ansichar(LocalInput[StartPosition+1]));
  -   end;
  -   case NextChar of
  -    $0a,$0d,$85,$2028,$2029:begin
  -     Start:=sskBeginLine;
  -     Flags:=sfEmptyBeginLine;
  -    end;
  -    else begin
  -     if Instance.IsWordChar(NextChar) then begin
  -      Start:=sskAfterWordChar;
  -      Flags:=sfDFALastWord;
  -     end else begin
  -      Start:=sskAfterNonWordChar;
  -      Flags:=0;
  -     end;
  -    end;
  -   end;
  -  end;
  - end;
  -
  - StartInstruction:=Instance.ReversedStartInstruction;
  - inc(Start,sskReversed);
  -
  - StartState:=@StartStates[Start];
  - if assigned(StartState^) then begin
  -  State:=StartState^;
  - end else begin
  -  WorkQueues[0].Clear;
  -  AddToWorkQueue(WorkQueues[0],StartInstruction,Flags);
  -  State:=WorkQueueToCachedState(WorkQueues[0],Flags);
  -  StartState^:=State;
  - end;
  -
  - for Position:=StartPosition downto UntilIncludingPosition-1 do begin //-1 because match can be delayed of one byte
  -  LastState:=State;
  -  if Position>=0 then begin
  -   CurrentChar:=byte(ansichar(LocalInput[Position]));
  -  end else begin
  -   CurrentChar:=256;
  -  end;
  -  State:=State^.NextStates[LocalByteMap[CurrentChar]];
  -  if not assigned(State) then begin
  -   State:=RunStateOnByte(LastState,Position,CurrentChar,true);
  +    CurrentChar:=256;
  +   end;
  +
  +   LastState:=State;
  +   State:=State^.NextStates[LocalByteMap^[CurrentChar]];
      if not assigned(State) then begin
  -    result:=DFAError;
  -    exit;
  -   end;
  -  end;
  -  if (State^.Flags and (sfDFAMatchWins or sfDFADead))<>0 then begin
  -   if (State^.Flags and sfDFADead)<>0 then begin
  -    if result<>DFAMatch then begin
  -     result:=DFAFail;
  -    end;
  -    exit;
  -   end;
  -   if (State^.Flags and sfDFAMatchWins)<>0 then begin
  -    MatchBegin:=Position+1;
  -    result:=DFAMatch;
  -   end;
  -  end;
  - end;
  - 
  +    State:=RunStateOnByte(LastState,Position,CurrentChar);
  +    if not assigned(State) then begin
  +     result:=DFAError;
  +     exit;
  +    end;
  +   end;
  +   if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
  +    if (State^.Flags and sfDFADead)<>0 then begin
  +     if result<>DFAMatch then begin
  +      result:=DFAFail;
  +     end;
  +     exit;
  +    end;
  +    if (State^.Flags and sfDFAFullMatch)<>0 then begin
  +     MatchEnd:=UntilExcludingPosition-1;
  +     result:=DFAMatch;
  +     exit;
  +    end;
  +    if (State^.Flags and sfDFAMatchWins)<>0 then begin
  +     MatchEnd:=Position-1;
  +     result:=DFAMatch;
  +    end;
  +   end;
  +
  +  end;
  +
  + end;
  +
   end;
   
   constructor TFLREThreadLocalStorageInstance.Create(AInstance:TFLRE);
  
positive.code: 
   IsUnanchored:=false;
  
   StackInstructions:=nil;
   StateCache:=TFLREDFAStateHashMap.Create;
   NextStatesSize:=0;
  
negative.code:  end;
  end;
  
  function TFLREDFA.RunStateOnByte(State:PFLREDFAState;const Position:longint;const CurrentChar:longword):PFLREDFAState;
  var Counter:longint;
      Instruction:PFLREInstruction;
      NeedFlags,BeforeFlags,OldBeforeFlags,AfterFlags,Flags,UnicodeChar:longword;
  