anchor.diff:    l := FHashTreeOperations.LockList;
     try
       P := l[index];
  -
  +    // Delete from Ordered by OpReference
  +    if Not FListOrderedByOpReference.FindOpReference(P^.Op.GetOpReference,i) then begin
  +      TLog.NewLog(ltError,ClassName,'DEV ERROR 20180629-1 Operation not found in ordered by reference list: '+P^.Op.ToString);
  +    end else FListOrderedByOpReference.Delete(i);
       // Delete from Ordered
       If Not FindOrderedBySha(l,P^.Op.Sha256,iDel) then begin
         TLog.NewLog(ltError,ClassName,'DEV ERROR 20180213-1 Operation not found in ordered list: '+P^.Op.ToString);
  
positive.code:   SetLength(FHashTree,0);
    FreeAndNil(FListOrderedBySha256);
    FreeAndNil(FListOrderedByAccountsData);
    inherited;
  end;
  
  
negative.code:   end;
  end;
  
  { TOrderedOpReferenceList }
  
  {$UNDEF IS64BITS}
  {$IFDEF CPU64BITS}{$DEFINE IS64BITS}{$ENDIF}
  {$IFDEF FPC}{$IFDEF CPU64}{$DEFINE IS64BITS}{$ENDIF}{$ENDIF}
  {$IFNDEF IS64BITS}
  Type POpReference = ^TOpReference;
  {$ENDIF}
  
  function TOrderedOpReferenceList.Add(AOpReference: TOpReference) : Integer;
    {$IFNDEF IS64BITS}
  var p : POpReference;
    {$ENDIF}
  begin
    FindOpReference(AOpReference,Result);
    // Will allow duplicates
    {$IFNDEF IS64BITS}
    new(p);
    p^ := AOpReference;
    FList.Insert(Result,p);
    {$ELSE}
    FList.Insert(Result,TObject(AOpReference));
    {$ENDIF}
  end;
  
  procedure TOrderedOpReferenceList.Clear;
  Var i : Integer;
    {$IFNDEF IS64BITS}
    p : POpReference;
    {$ENDIF}
  begin
    {$IFNDEF IS64BITS}
    for i := 0 to FList.Count-1 do begin
      p := FList[i];
      Dispose(p);
    end;
    {$ENDIF}
    FList.Clear;
  end;
  
  function TOrderedOpReferenceList.Count: Integer;
  begin
    Result := FList.Count;
  end;
  
  constructor TOrderedOpReferenceList.Create;
  begin
    FList := TList.Create;
  end;
  
  procedure TOrderedOpReferenceList.Delete(AIndex: Integer);
    {$IFNDEF IS64BITS}
  var p : POpReference;
    {$ENDIF}
  begin
    {$IFNDEF IS64BITS}
    p := FList[AIndex];
    Dispose(p);
    {$ENDIF}
    FList.Delete(AIndex);
  end;
  
  destructor TOrderedOpReferenceList.Destroy;
  begin
    Clear;
    FreeAndNil(FList);
    inherited;
  end;
  
  function TOrderedOpReferenceList.FindAccount(AAccount: Cardinal; var Index: Integer): Boolean;
  var
    cCurrent : TOpReference;
  begin
    Result := FindOpReference((AAccount SHL 32),Index);
    if (Not Result) And (Index<FList.Count) then begin
      // Check if Index is same AAccount value
      {$IFNDEF IS64BITS}
      cCurrent := POpReference( FList[Index] )^;
      {$ELSE}
      cCurrent := TOpReference(FList[Index]);
      {$ENDIF}
      if (cCurrent SHR 32)=AAccount then Result := True;
    end;
  end;
  
  function TOrderedOpReferenceList.FindOpReference(AOpReference: TOpReference; var Index: Integer): Boolean;
  var L, H, I: Integer;
    cCurrent : TOpReference;
    C : Int64;
  begin
    Result := False;
    L := 0;
    H := FList.Count - 1;
    while L <= H do
    begin
      I := (L + H) shr 1;
      // Capture value
      {$IFNDEF IS64BITS}
      cCurrent := POpReference( FList[I] )^;
      {$ELSE}
      cCurrent := TOpReference(FList[I]);
      {$ENDIF}
  
      C := Int64(cCurrent) - Int64(AOpReference);
      if C < 0 then L := I + 1 else
      begin
        H := I - 1;
        if C = 0 then
        begin
          Result := True;
          L := I;
        end;
      end;
    end;
    Index := L;
  end;
  
  function TOrderedOpReferenceList.Get(AIndex: Integer): TOpReference;
  begin
    {$IFNDEF IS64BITS}
    Result := POpReference( FList[AIndex] )^;
    {$ELSE}
    Result := TOpReference(FList[AIndex]);
    {$ENDIF}
  end;
  
  function TOrderedOpReferenceList.IndexOf(AOpReference: TOpReference): Integer;
  begin
    if Not FindOpReference(AOpReference,Result) then Result := -1;
  end;
  
  function TOrderedOpReferenceList.IndexOfAccount(AAccount: Cardinal): Integer;
  begin
    if Not FindAccount(AAccount,Result) then Result := -1;
  end;
  
  initialization
    SetLength(_OperationsClass, 0);
    RegisterOperationsClass;
  