anchor.diff:  
    BitStateNFA.Free;
   
  - DFADestroyStatePool(DFAStatePoolUsed);
  - DFADestroyStatePool(DFAStatePoolFree);
  - DFAStatePoolUsed:=nil;
  - DFAStatePoolFree:=nil;
  - DFAFreeState(@DFATemporaryState);
  - DFAFreeState(@DFANewState);
  - for Index:=0 to length(DFAStates)-1 do begin
  -  if assigned(DFAStates[Index]) then begin
  -   DFAFreeState(DFAStates[Index]);
  -   FreeMem(DFAStates[Index]);
  -  end;
  - end;
  - FreeAndNil(DFAStateCache);
  - SetLength(DFAStackInstructions,0);
  - SetLength(DFAInstructionGenerations,0);
  + DFA.Free;
  + ReversedDFA.Free;
   
    inherited Destroy;
   end;
  
positive.code:   BitStateNFA:=nil;
   end;
  
   DFAStackInstructions:=nil;
   DFAStateCache:=TFLREDFAStateHashMap.Create;
   DFANextStatesSize:=0;
   DFAStateSize:=0;
   DFAStatePoolUsed:=nil;
   DFAStatePoolFree:=nil;
   DFAStatePoolSize:=0;
   DFAStatePoolSizePowerOfTwo:=0;
   FillChar(DFAStates,SizeOf(DFAStates),AnsiChar(#0));
  
   begin
    DFACountStatesCached:=0;
  
    DFAStackInstructions:=nil;
    SetLength(DFAStackInstructions,Max(AInstance.CountForwardInstructions,AInstance.CountBackwardInstructions) shl 1);
  
    DFAStatePoolUsed:=nil;
    DFAStatePoolFree:=nil;
  
    DFANextStatesSize:=AInstance.ByteMapCount*sizeof(PFLREDFAState);
    DFAStateSize:=ptrint(ptruint(pointer(@FLREDFAStateCreateTempDFAState.NextStates))-ptruint(pointer(@FLREDFAStateCreateTempDFAState)))+DFANextStatesSize;
  
    DFAStatePoolSize:=(65536 div DFAStateSize)*DFAStateSize;
    if DFAStatePoolSize=0 then begin
     DFAStatePoolSize:=DFAStateSize*64;
    end;
  
    DFAStatePoolSizePowerOfTwo:=RoundUpToPowerOfTwo(DFAStatePoolSize);
  
    DFAAllocateNewStatePool;
  
    FillChar(DFATemporaryState,SizeOf(TFLREDFAState),AnsiChar(#0));
    FillChar(DFANewState,SizeOf(TFLREDFAState),AnsiChar(#0));
  
    DFAInstructionGenerations:=nil;
    SetLength(DFAInstructionGenerations,Max(AInstance.CountForwardInstructions,AInstance.CountBackwardInstructions));
    for Index:=0 to length(DFAInstructionGenerations)-1 do begin
     DFAInstructionGenerations[Index]:=-1;
    end;
  
    if Instance.DFAFast then begin
  
     inc(DFAGeneration);
     GetMem(DFAState,DFAStateSize);
     FillChar(DFAState^,DFAStateSize,AnsiChar(#0));
     DFAFastAddInstructionThread(DFAState,Instance.AnchoredStartInstruction);
     DFAState^.Flags:=DFAState^.Flags or sfDFAStart;
     DFAStateCache.Add(DFAState);
     inc(DFACountStatesCached);
     DFAStates[skFast+skAnchored]:=DFAState;
  
     inc(DFAGeneration);
     GetMem(DFAState,DFAStateSize);
     FillChar(DFAState^,DFAStateSize,AnsiChar(#0));
     DFAFastAddInstructionThread(DFAState,Instance.UnanchoredStartInstruction);
     DFAState^.Flags:=DFAState^.Flags or sfDFAStart;
     DFAStateCache.Add(DFAState);
     inc(DFACountStatesCached);
     DFAStates[skFast+skUnanchored]:=DFAState;
  
     inc(DFAGeneration);
     GetMem(DFAState,DFAStateSize);
     FillChar(DFAState^,DFAStateSize,AnsiChar(#0));
     DFAFastAddInstructionThread(DFAState,Instance.ReversedStartInstruction);
     DFAState^.Flags:=DFAState^.Flags or sfDFAStart;
     DFAStateCache.Add(DFAState);
     inc(DFACountStatesCached);
     DFAStates[skFast+skReversed]:=DFAState;
  
    end;
  
    inc(DFAGeneration);
    GetMem(DFAState,DFAStateSize);
    FillChar(DFAState^,DFAStateSize,AnsiChar(#0));
    DFAFastAddInstructionThread(DFAState,Instance.AnchoredStartInstruction);
    DFAState^.Flags:=DFAState^.Flags or sfDFADead;
    DFAStateCache.Add(DFAState);
    inc(DFACountStatesCached);
    DFAStates[skDead]:=DFAState;
  
   end;
  
  end;
  
  destructor TFLREThreadLocalStorageInstance.Destroy;
  var Index,SubIndex:longint;
  begin
  
   ParallelNFA.Free;
  
negative.code:    end;
    end;
   end else begin
    case ThreadLocalStorageInstance.DFA.SearchMatchFull(StartPosition,UntilExcludingPosition,MatchEnd,UnanchoredStart) of
     DFAMatch:begin
      if UnanchoredStart then begin
       // For unanchored searchs, we must do also a "backward" DFA search
       case ThreadLocalStorageInstance.ReversedDFA.SearchMatchFullReversed(MatchEnd,StartPosition,MatchBegin) of
        DFAMatch:begin
         if MatchBegin<StartPosition then begin
          MatchBegin:=StartPosition;
  