anchor.diff:  
   end;
   
  +procedure TFLREDFA.DestroyStatePool(var StatePool:PFLREDFAStatePool);
  +var Pool,NextPool:PFLREDFAStatePool;
  +    State:PFLREDFAState;
  +begin
  + Pool:=StatePool;
  + StatePool:=nil;
  + while assigned(Pool) do begin
  +  NextPool:=Pool^.Next;
  +  State:=Pool^.States;
  +  while assigned(State) and (State<>Pool^.EndState) do begin
  +   FreeState(State);
  +   inc(ptruint(State),StateSize);
  +  end;
  +  FreeMem(Pool^.States);
  +  FreeMem(Pool);
  +  Pool:=NextPool;
  + end;
  +end;
  +
  +procedure TFLREDFA.FreeUsedStatePool;
  +var Pool,NextPool:PFLREDFAStatePool;
  +    State:PFLREDFAState;
  +begin
  + Pool:=StatePoolUsed;
  + StatePoolUsed:=nil;
  + while assigned(Pool) do begin
  +  NextPool:=Pool^.Next;
  +  State:=Pool^.States;
  +  while assigned(State) and (State<>Pool^.EndState) do begin
  +   FreeState(State);
  +   inc(ptruint(State),StateSize);
  +  end;
  +  FillChar(Pool^.States^,StatePoolSize,AnsiChar(#0));
  +  Pool^.Next:=StatePoolFree;
  +  StatePoolFree:=Pool;
  +  Pool:=NextPool;
  + end;
  +end;
  +
  +function TFLREDFA.AllocateNewStatePool:PFLREDFAStatePool;
  +begin
  + if assigned(StatePoolFree) then begin
  +  result:=StatePoolFree;
  +  StatePoolFree:=result^.Next;
  + end else begin
  +  GetMem(result,SizeOf(TFLREDFAStatePool));
  +  FillChar(result^,SizeOf(TFLREDFAStatePool),AnsiChar(#0));
  +  GetMem(result^.States,StatePoolSizePowerOfTwo);
  +  FillChar(result^.States^,StatePoolSize,AnsiChar(#0));
  +  result^.EndState:=pointer(ptruint(ptruint(result^.States)+ptruint(StatePoolSize)));
  + end;
  + result^.Next:=StatePoolUsed;
  + StatePoolUsed:=result;
  + result^.NextState:=result^.States;
  +end;
  +
  +function TFLREDFA.GetState:PFLREDFAState;
  +begin
  + if StatePoolUsed^.NextState=StatePoolUsed^.EndState then begin
  +  AllocateNewStatePool;
  + end;
  + result:=StatePoolUsed^.NextState;
  + inc(ptruint(StatePoolUsed^.NextState),StateSize);
  +end;
  +
  +function TFLREDFA.TakeOverState(TakeOverFrom:PFLREDFAState):PFLREDFAState;
  +begin
  + result:=GetState;
  + result^.Instructions:=TakeOverFrom^.Instructions;
  + result^.CountInstructions:=TakeOverFrom^.CountInstructions;
  + result^.Flags:=TakeOverFrom^.Flags;
  + TakeOverFrom^.Instructions:=nil;
  + TakeOverFrom^.CountInstructions:=0;
  + TakeOverFrom^.Flags:=0;
  +end;
  +
  +procedure TFLREDFA.FreeState(State:PFLREDFAState);
  +begin
  + if assigned(State) then begin
  +  SetLength(State^.Instructions,0);
  +  if assigned(StatePoolUsed) and
  +     ((ptruint(ptruint(State)-ptruint(StatePoolUsed^.States))<StatePoolSize) and
  +      (pointer(ptruint(ptruint(StatePoolUsed^.NextState)-ptruint(StateSize)))=State)) then begin
  +   FillChar(State^,StateSize,AnsiChar(#0));
  +   dec(ptruint(StatePoolUsed^.NextState),StateSize);
  +  end;
  + end;
  +end;
  +
  +procedure TFLREDFA.Reset;
  +var Index:longint;
  +    State:PFLREDFAState;
  +begin
  +
  + // Reset state pools
  + FreeUsedStatePool;
  + AllocateNewStatePool;
  +
  + // Reset state cache
  + StateCache.Clear;
  + CountStatesCached:=0;
  +
  + // Reset and recaching start states
  + for Index:=0 to length(DefaultStates)-1 do begin
  +  State:=DefaultStates[Index];
  +  if assigned(State) then begin
  +   FillChar(State^.NextStates,NextStatesSize,AnsiChar(#0));
  +   StateCache.Add(State);
  +   inc(CountStatesCached);
  +  end;
  + end;
  +
  +end;
  +
  +
   procedure TFLREDFA.FastAddInstructionThread(const State:PFLREDFAState;Instruction:PFLREInstruction);
   var StackPointer:longint;
       Stack:PPFLREInstructionsStatic;
  
positive.code:  end;
  end;
  
  function TFLREDFA.FastProcessNextState(State:PFLREDFAState;const CurrentChar:ansichar;const Reversed:boolean):PFLREDFAState;
  var Counter:longint;
      Instruction:PFLREInstruction;
  begin
  
   // Process state instructions
   inc(Generation);
   NewState.CountInstructions:=0;
   NewState.Flags:=(State^.Flags and sfDFAStart) shl sfDFANeedShift;
   for Counter:=0 To State^.CountInstructions-1 do begin
    Instruction:=State^.Instructions[Counter];
    case Instruction^.IDandOpcode and $ff of
     opSINGLECHAR:begin
      if byte(ansichar(CurrentChar))=Instruction^.Value then begin
       FastAddInstructionThread(@NewState,Instruction^.Next);
      end;
     end;
     opCHAR:begin
      if CurrentChar in PFLRECharClass(pointer(ptruint(Instruction^.Value)))^ then begin
       FastAddInstructionThread(@NewState,Instruction^.Next);
      end;
     end;
     opANY:begin
      FastAddInstructionThread(@NewState,Instruction^.Next);
     end;
     opMATCH:begin
      if not (SearchLongest or Reversed) then begin
       // We can stop processing the instruction list queue here since we found a match (for the PCRE leftmost first valid match behaviour)
       break;
      end;
     end;
     else begin
      // Oops?! Invalid byte code instruction for the DFA processing context! So abort and fallback to NFA...
      result:=nil;
      exit;
     end;
    end;
   end;
  
   // Dead state? If yes, ...
   if NewState.CountInstructions=0 then begin
    // ... drop it and take the dead state as the next state
    result:=DefaultStates[skDead];
   end else begin
    // .. otherwise try caching it
    result:=CacheState(@NewState);
   end;
  
   // Connect the last state to the new state with the current char
   State.NextStates[Instance.ByteMap[byte(ansichar(CurrentChar))]]:=result;
  
  end;
  
  function TFLREDFA.FullProcessNextState(State:PFLREDFAState;const Position:longint;const CurrentChar:longword;const Reversed:boolean):PFLREDFAState;
  var Counter:longint;
      Instruction:PFLREInstruction;
  
negative.code:  end;
  end;
  
  function TFLREDFA.FastProcessNextState(State:PFLREDFAState;const CurrentChar:ansichar;const Reversed:boolean):PFLREDFAState;
  var Counter:longint;
      Instruction:PFLREInstruction;
  begin
  
   // Process state instructions
   inc(Generation);
   NewState.CountInstructions:=0;
   NewState.Flags:=(State^.Flags and sfDFAStart) shl sfDFANeedShift;
   for Counter:=0 To State^.CountInstructions-1 do begin
    Instruction:=State^.Instructions[Counter];
    case Instruction^.IDandOpcode and $ff of
     opSINGLECHAR:begin
      if byte(ansichar(CurrentChar))=Instruction^.Value then begin
       FastAddInstructionThread(@NewState,Instruction^.Next);
      end;
     end;
     opCHAR:begin
      if CurrentChar in PFLRECharClass(pointer(ptruint(Instruction^.Value)))^ then begin
       FastAddInstructionThread(@NewState,Instruction^.Next);
      end;
     end;
     opANY:begin
      FastAddInstructionThread(@NewState,Instruction^.Next);
     end;
     opMATCH:begin
      if not (SearchLongest or Reversed) then begin
       // We can stop processing the instruction list queue here since we found a match (for the PCRE leftmost first valid match behaviour)
       break;
      end;
     end;
     else begin
      // Oops?! Invalid byte code instruction for the DFA processing context! So abort and fallback to NFA...
      result:=nil;
      exit;
     end;
    end;
   end;
  
   // Dead state? If yes, ...
   if NewState.CountInstructions=0 then begin
    // ... drop it and take the dead state as the next state
    result:=DefaultStates[skDead];
   end else begin
    // .. otherwise try caching it
    result:=CacheState(@NewState);
   end;
  
   // Connect the last state to the new state with the current char
   State.NextStates[Instance.ByteMap[byte(ansichar(CurrentChar))]]:=result;
  
  end;
  
  function TFLREDFA.SearchMatchFast(const StartPosition,UntilExcludingPosition:longint;out MatchEnd:longint;const UnanchoredStart:boolean):longint;
  var Position:longint;
      State,LastState:PFLREDFAState;
      LocalInput:pansichar;
      LocalByteMap:PFLREByteMap;
  begin
   result:=DFAFail;
   LocalInput:=ThreadLocalStorageInstance.Input;
   LocalByteMap:=@Instance.ByteMap;
   if UnanchoredStart then begin
    State:=DefaultStates[skFast+skUnanchored];
   end else begin
    State:=DefaultStates[skFast+skAnchored];
   end;
   for Position:=StartPosition to UntilExcludingPosition-1 do begin
    LastState:=State;
    State:=State^.NextStates[LocalByteMap[byte(ansichar(LocalInput[Position]))]];
    if not assigned(State) then begin
     State:=FastProcessNextState(LastState,LocalInput[Position],false);
     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;
      result:=DFAMatch;
     end;
    end;
   end;
  end;
  
  function TFLREDFA.SearchMatchFastReversed(const StartPosition,UntilIncludingPosition:longint;out MatchBegin:longint):longint;
  var Position:longint;
      State,LastState:PFLREDFAState;
      LocalInput:pansichar;
      LocalByteMap:PFLREByteMap;
  begin
   result:=DFAFail;
   LocalInput:=ThreadLocalStorageInstance.Input;
   LocalByteMap:=@Instance.ByteMap;
   State:=DefaultStates[skFast+skReversed];
   for Position:=StartPosition downto UntilIncludingPosition do begin
    LastState:=State;
    State:=State^.NextStates[LocalByteMap[byte(ansichar(LocalInput[Position]))]];
    if not assigned(State) then begin
     State:=FastProcessNextState(LastState,LocalInput[Position],true);
     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;
      result:=DFAMatch;
     end;
    end;
   end;
  end;
  
  procedure TFLREDFA.FullAddInstructionThread(const State:PFLREDFAState;Instruction:PFLREInstruction;const Flags:longword);
  var StackPointer:longint;
      Stack:PPFLREInstructionsStatic;
  