anchor.diff:      CurrentThreadList,NewThreadList,TemporaryThreadList:PThreadList;
       CurrentThread:PThread;
       Instruction:PFLREInstruction;
  -    CurrentChar:ansichar;
  +    CurrentChar:TFLRERawByteChar;
       ThreadLists:TThreadLists;
       HasCountPrefixCharClasses:boolean;
   begin
   
    Generation:=0;
   
  - InstructionGenerations:=nil;
  + PrefixCharClasses:=nil;
    try
   
  -  SetLength(InstructionGenerations,CountForwardInstructions+1);
  -  for Index:=0 to length(InstructionGenerations)-1 do begin
  -   InstructionGenerations[Index]:=-1;
  -  end;
  -
  -  for CurrentPosition:=0 to FLREMaxPrefixCharClasses-1 do begin
  -   PrefixCharClasses[CurrentPosition]:=[];
  -  end;
  -
  -  CountPrefixCharClasses:=0;
  -  HasCountPrefixCharClasses:=false;
  -
  -  ThreadLists[0].Threads:=nil;
  -  ThreadLists[1].Threads:=nil;
  +  InstructionGenerations:=nil;
     try
  -   SetLength(ThreadLists[0].Threads,(CountForwardInstructions+1)*4);
  -   SetLength(ThreadLists[1].Threads,(CountForwardInstructions+1)*4);
  -
  -   CurrentThreadList:=@ThreadLists[0];
  -   NewThreadList:=@ThreadLists[1];
  -
  -   CurrentThreadList^.Count:=0;
  -   NewThreadList^.Count:=0;
  -
  -   Generation:=1;
  -   CurrentPosition:=0;
  -   AddThread(CurrentThreadList,AnchoredStartInstruction);
  -
  -   Count:=0;
  -
  -   for CurrentPosition:=0 to FLREMaxPrefixCharClasses do begin
  -    if CurrentThreadList^.Count=0 then begin
  -     break;
  -    end;
  -    inc(Generation);
  -    inc(Count);
  -    for ThreadIndex:=0 to CurrentThreadList^.Count-1 do begin
  -     CurrentThread:=@CurrentThreadList^.Threads[ThreadIndex];
  -     Instruction:=CurrentThread^.Instruction;
  -     case Instruction^.IDandOpcode and $ff of
  -      opNONE:begin
  -       // Match against nothing
  -       HasCountPrefixCharClasses:=true;
  -      end;
  -      opSINGLECHAR:begin
  -       if CurrentPosition<FLREMaxPrefixCharClasses then begin
  -        PrefixCharClasses[CurrentPosition]:=PrefixCharClasses[CurrentPosition]+[ansichar(byte(Instruction^.Value))];
  +
  +   SetLength(PrefixCharClasses,FLREMaxPrefixCharClasses);
  +
  +   SetLength(InstructionGenerations,CountForwardInstructions+1);
  +   for Index:=0 to length(InstructionGenerations)-1 do begin
  +    InstructionGenerations[Index]:=-1;
  +   end;
  +
  +   for CurrentPosition:=0 to FLREMaxPrefixCharClasses-1 do begin
  +    PrefixCharClasses[CurrentPosition]:=[];
  +   end;
  +
  +   CountPrefixCharClasses:=0;
  +   HasCountPrefixCharClasses:=false;
  +
  +   ThreadLists[0].Threads:=nil;
  +   ThreadLists[1].Threads:=nil;
  +   try
  +    SetLength(ThreadLists[0].Threads,(CountForwardInstructions+1)*4);
  +    SetLength(ThreadLists[1].Threads,(CountForwardInstructions+1)*4);
  +
  +    CurrentThreadList:=@ThreadLists[0];
  +    NewThreadList:=@ThreadLists[1];
  +
  +    CurrentThreadList^.Count:=0;
  +    NewThreadList^.Count:=0;
  +
  +    Generation:=1;
  +    CurrentPosition:=0;
  +    AddThread(CurrentThreadList,AnchoredStartInstruction);
  +
  +    Count:=0;
  +
  +    for CurrentPosition:=0 to FLREMaxPrefixCharClasses do begin
  +     if CurrentThreadList^.Count=0 then begin
  +      break;
  +     end;
  +     inc(Generation);
  +     inc(Count);
  +     for ThreadIndex:=0 to CurrentThreadList^.Count-1 do begin
  +      CurrentThread:=@CurrentThreadList^.Threads[ThreadIndex];
  +      Instruction:=CurrentThread^.Instruction;
  +      case Instruction^.IDandOpcode and $ff of
  +       opNONE:begin
  +        // Match against nothing
  +        HasCountPrefixCharClasses:=true;
          end;
  -       AddThread(NewThreadList,Instruction^.Next);
  -      end;
  -      opCHAR:begin
  -       if CurrentPosition<FLREMaxPrefixCharClasses then begin
  -        PrefixCharClasses[CurrentPosition]:=PrefixCharClasses[CurrentPosition]+PFLRECharClass(pointer(ptruint(Instruction^.Value)))^;
  +       opSINGLECHAR:begin
  +        if CurrentPosition<FLREMaxPrefixCharClasses then begin
  +         PrefixCharClasses[CurrentPosition]:=PrefixCharClasses[CurrentPosition]+[TFLRERawByteChar(byte(Instruction^.Value))];
  +        end;
  +        AddThread(NewThreadList,Instruction^.Next);
          end;
  -       AddThread(NewThreadList,Instruction^.Next);
  -      end;
  -      opANY:begin
  -       if CurrentPosition<FLREMaxPrefixCharClasses then begin
  -        PrefixCharClasses[CurrentPosition]:=PrefixCharClasses[CurrentPosition]+AllCharClass;
  +       opCHAR:begin
  +        if CurrentPosition<FLREMaxPrefixCharClasses then begin
  +         PrefixCharClasses[CurrentPosition]:=PrefixCharClasses[CurrentPosition]+PFLRECharClass(pointer(ptruint(Instruction^.Value)))^;
  +        end;
  +        AddThread(NewThreadList,Instruction^.Next);
          end;
  -       AddThread(NewThreadList,Instruction^.Next);
  -      end;
  -      opMATCH:begin
  -       if CountPrefixCharClasses=0 then begin
  -        CountPrefixCharClasses:=CurrentPosition;
  -        if CountPrefixCharClasses>0 then begin
  -         HasCountPrefixCharClasses:=true;
  +       opANY:begin
  +        if CurrentPosition<FLREMaxPrefixCharClasses then begin
  +         PrefixCharClasses[CurrentPosition]:=PrefixCharClasses[CurrentPosition]+AllCharClass;
  +        end;
  +        AddThread(NewThreadList,Instruction^.Next);
  +       end;
  +       opMATCH:begin
  +        if CountPrefixCharClasses=0 then begin
  +         CountPrefixCharClasses:=CurrentPosition;
  +         if CountPrefixCharClasses>0 then begin
  +          HasCountPrefixCharClasses:=true;
  +         end;
           end;
          end;
         end;
        end;
  -    end;
  -    TemporaryThreadList:=CurrentThreadList;
  -    CurrentThreadList:=NewThreadList;
  -    NewThreadList:=TemporaryThreadList;
  -    NewThreadList^.Count:=0;
  -   end;
  -
  -   if not HasCountPrefixCharClasses then begin
  -    CountPrefixCharClasses:=Count;
  -    if CountPrefixCharClasses>FLREMaxPrefixCharClasses then begin
  -     CountPrefixCharClasses:=FLREMaxPrefixCharClasses;
  -    end;
  -   end;
  -
  -   TotalCount:=0;
  -   for CurrentPosition:=0 to CountPrefixCharClasses-1 do begin
  -    Count:=0;
  -    for CurrentChar:=#0 to #255 do begin
  -     if CurrentChar in PrefixCharClasses[CurrentPosition] then begin
  -      inc(Count);
  -     end;
  -    end;
  -    inc(TotalCount,Count);
  -   end;
  -
  -   if CountPrefixCharClasses>0 then begin
  -    AveragePrefixCharClassesVariance:=(TotalCount+((CountPrefixCharClasses+1) div 2)) div CountPrefixCharClasses;
  -   end else begin
  -    AveragePrefixCharClassesVariance:=255;
  -   end;
  -
  -   case CountPrefixCharClasses of
  -    0..2:begin
  -     // For so short prefixes it would be overkill in the most cases, and SBNDMQ2 do need a prefix pattern of length 3 at least 
  -     Exclude(InternalFlags,fifDFAFastBeginningSearch);
  -    end;
  -    3..15:begin
  -     if AveragePrefixCharClassesVariance<(((CountPrefixCharClasses*128)+8) shr 4) then begin
  -      Include(InternalFlags,fifDFAFastBeginningSearch);
  -     end else begin
  +     TemporaryThreadList:=CurrentThreadList;
  +     CurrentThreadList:=NewThreadList;
  +     NewThreadList:=TemporaryThreadList;
  +     NewThreadList^.Count:=0;
  +    end;
  +
  +    if not HasCountPrefixCharClasses then begin
  +     CountPrefixCharClasses:=Count;
  +     if CountPrefixCharClasses>FLREMaxPrefixCharClasses then begin
  +      CountPrefixCharClasses:=FLREMaxPrefixCharClasses;
  +     end;
  +    end;
  +
  +    TotalCount:=0;
  +    for CurrentPosition:=0 to CountPrefixCharClasses-1 do begin
  +     Count:=0;
  +     for CurrentChar:=low(TFLRERawByteChar) to high(TFLRERawByteChar) do begin
  +      if CurrentChar in PrefixCharClasses[CurrentPosition] then begin
  +       inc(Count);
  +      end;
  +     end;
  +     inc(TotalCount,Count);
  +    end;
  +
  +    if CountPrefixCharClasses>0 then begin
  +     AveragePrefixCharClassesVariance:=(TotalCount+((CountPrefixCharClasses+1) div 2)) div CountPrefixCharClasses;
  +    end else begin
  +     AveragePrefixCharClassesVariance:=255;
  +    end;
  +
  +    case CountPrefixCharClasses of
  +     0..2:begin
  +      // For so short prefixes it would be overkill in the most cases, and SBNDMQ2 do need a prefix pattern of length 3 at least
         Exclude(InternalFlags,fifDFAFastBeginningSearch);
        end;
  -    end;
  -    else begin
  -     if AveragePrefixCharClassesVariance<128 then begin
  -      Include(InternalFlags,fifDFAFastBeginningSearch);
  -     end else begin
  -      Exclude(InternalFlags,fifDFAFastBeginningSearch);
  -     end;
  -    end;
  -   end;
  -
  -   CompilePrefixPattern;
  +     3..15:begin
  +      if AveragePrefixCharClassesVariance<(((CountPrefixCharClasses*128)+8) shr 4) then begin
  +       Include(InternalFlags,fifDFAFastBeginningSearch);
  +      end else begin
  +       Exclude(InternalFlags,fifDFAFastBeginningSearch);
  +      end;
  +     end;
  +     else begin
  +      if AveragePrefixCharClassesVariance<128 then begin
  +       Include(InternalFlags,fifDFAFastBeginningSearch);
  +      end else begin
  +       Exclude(InternalFlags,fifDFAFastBeginningSearch);
  +      end;
  +     end;
  +    end;
  +
  +    CompilePrefixPattern;
  +
  +    if CountPrefixCharClasses=1 then begin
  +     FirstPrefixCharClassSize:=TotalCount;
  +     case FirstPrefixCharClassSize of
  +      1..8:begin
  +       SetLength(FirstPrefixCharClassChars,FirstPrefixCharClassSize);
  +       Count:=0;
  +       for CurrentChar:=low(TFLRERawByteChar) to high(TFLRERawByteChar) do begin
  +        if CurrentChar in PrefixCharClasses[0] then begin
  +         FirstPrefixCharClassChars[Count]:=CurrentChar;
  +         inc(Count);
  +        end;
  +       end;
  +      end;
  +      else begin
  +       if not assigned(FirstPrefixCharClass) then begin
  +        GetMem(FirstPrefixCharClass,SizeOf(TFLRECharClass));
  +       end;
  +       FirstPrefixCharClass^:=PrefixCharClasses[0];
  +      end;
  +     end;
  +    end;
  +
  +   finally
  +    SetLength(ThreadLists[0].Threads,0);
  +    SetLength(ThreadLists[1].Threads,0);
  +   end;
   
     finally
  -   SetLength(ThreadLists[0].Threads,0);
  -   SetLength(ThreadLists[1].Threads,0);
  +   SetLength(InstructionGenerations,0);
     end;
   
    finally
  -  SetLength(InstructionGenerations,0);
  - end;
  +  SetLength(PrefixCharClasses,0);
  + end;
  +
   end;
   
   procedure TFLRE.CompileByteMapForOnePassNFAAndDFA;
   var Node:PFLRENode;
       i,ByteCount:longint;
  -    CurrentChar:ansichar;
  +    CurrentChar:TFLRERawByteChar;
       CharSetMap:TFLRECharClass;
       CharClass,NodeCharClass:TFLRECharClass;
       NewLines,Words:boolean;
  
positive.code:       end;
        else begin
         if (rfIGNORECASE in Flags) and (Source[SourcePosition] in ['a'..'z','A'..'Z']) then begin
          UnicodeChar:=byte(ansichar(Source[SourcePosition]));
          inc(SourcePosition);
          LowerCaseUnicodeChar:=UnicodeToLower(UnicodeChar);
          UpperCaseUnicodeChar:=UnicodeToUpper(UnicodeChar);
          result:=NewNode(ntCHAR,nil,nil,NewCharClass([ansichar(byte(LowerCaseUnicodeChar)),ansichar(byte(UpperCaseUnicodeChar))],true));
         end else begin
          result:=NewNode(ntCHAR,nil,nil,NewCharClass([Source[SourcePosition]],true));
          inc(SourcePosition);
  
negative.code:      s:=TFLRERawByteString(e.Message);
       Len:=length(s);
       if Len>0 then begin
        GetMem(Error^,(Len+1)*SizeOf(TFLRERawByteChar));
        Move(s[1],Error^[0],Len);
        Error^[Len]:=#0;
       end else begin
  