Index: oup/current/Tools/BinEdit.pas
===================================================================
--- oup/current/Tools/BinEdit.pas	(revision 111)
+++ oup/current/Tools/BinEdit.pas	(revision 113)
@@ -140,5 +140,4 @@
 var
   mem:  TMemoryStream;
-  Data: TByteData;
 begin
   if ConID <> -1 then
@@ -183,4 +182,5 @@
   Data: TByteData;
   i:    Word;
+  tempi: Integer;
   floatformat: TFormatSettings;
 begin
@@ -218,8 +218,17 @@
       Result := IntToBin(hex.Data[offset]);
     11:
-      Result := '0x' + IntToHex(ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr, 8);
+    begin
+      tempi := ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr;
+      if tempi >= 0 then
+        Result := '0x' + IntToHex(tempi, 8)
+      else
+        Result := 'unused';
+    end;
     12:
-      Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
-        hex.Data[offset + 3] * 256 * 256, 5, '0');
+      if hex.Data[offset] = 1 then
+        Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
+          hex.Data[offset + 3] * 256 * 256, 5, '0')
+      else
+        Result := 'no link';
     13:
       Result := IntToStr(hex.Data[offset]);
@@ -308,6 +317,6 @@
               if Pos('#', SubName) > 0 then
               begin
-                Data.Offset  := HexToLong(MidStr(SubName, Pos('#', SubName) + 1, 8));
-                Data.Value   :=
+                Data.Offset  := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8));
+                Data.Value   := '$' +
                   MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8);
                 Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1);
@@ -749,10 +758,10 @@
     else
     begin
-      if nodedata.DataType = 11 then
+      if (nodedata.DataType = 11) and (nodedata.Value <> 'unused') then
       begin
         if ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset).RawSize > 0 then
           Form_Main.open_child('rawedit', ConID, fileid);
       end;
-      if nodedata.DataType = 12 then
+      if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then
       begin
         if (StrToInt(nodedata.Value) < ConManager.Connection[ConID].GetFileCount) and
@@ -794,5 +803,5 @@
   begin
     hex.SelStart := Data.Offset;
-    hex.SelEnd   := Data.Offset + HexToLong(Data.Value) - 1;
+    hex.SelEnd   := Data.Offset + StrToInt(Data.Value) - 1;
   end;
 end;
@@ -825,5 +834,5 @@
           CellText := Data.Value //GetValue(data.DataType, data.Offset)
         else if Length(Data.Value) > 0 then
-          CellText := IntToStr(HexToLong(Data.Value)) + ' Bytes';
+          CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes';
       4:
         CellText := Data.Description;
Index: oup/current/Tools/RawEdit.pas
===================================================================
--- oup/current/Tools/RawEdit.pas	(revision 111)
+++ oup/current/Tools/RawEdit.pas	(revision 113)
@@ -54,5 +54,5 @@
     procedure hexChange(Sender: TObject);
   private
-    ConID, fileid, datoffset: Integer;
+    fileid, datoffset: Integer;
   public
   end;
@@ -115,5 +115,5 @@
     for i := 0 to filelist.Count - 1 do
     begin
-      if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
+      if ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
       begin
         filelist.ItemIndex := i;
@@ -132,5 +132,5 @@
   end;
   mem := nil;
-  ConManager.Connection[ConID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem));
+  ConManager.Connection[ConnectionID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem));
   hex.LoadFromStream(mem);
   ClearValues;
@@ -148,5 +148,5 @@
   datoffset := StrToInt('$' + MidStr(
     list_offset.Items.Strings[list_offset.ItemIndex], 3, 8));
-  LoadRaw(ConManager.Connection[ConID].GetRawInfo(fileid, datoffset));
+  LoadRaw(ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset));
 end;
 
@@ -391,5 +391,5 @@
 begin
   case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' +
-      ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
+      ConManager.Connection[ConnectionID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
       MB_YESNOCANCEL) of
     idYes:
@@ -398,5 +398,5 @@
       hex.SaveToStream(mem);
       mem.Seek(0, soFromBeginning);
-      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, mem);
+      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, mem);
       mem.Free;
       hex.Modified := False;
@@ -506,8 +506,8 @@
 begin
   saved.Filter     := 'Files of matching extension (*.' +
-    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
-    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
+    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension + ')|*.' +
+    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension +
     '|All files|*.*';
-  saved.DefaultExt := ConManager.Connection[ConID].GetFileInfo(fileid).Extension;
+  saved.DefaultExt := ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension;
   if saved.Execute then
   begin
@@ -525,11 +525,10 @@
 //  Data: Tdata;
   fs:   TFileStream;
-  data: TByteData;
   i: Integer;
   rawinfo: TRawDataInfo;
 begin
   opend.Filter := 'Files of matching extension (*.' +
-    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
-    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
+    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension + ')|*.' +
+    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension +
     '|All files|*.*';
   if opend.Execute then
@@ -538,5 +537,5 @@
     if fs.Size <> hex.DataSize then
     begin
-      if (not (CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
+      if (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
       begin
         ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
@@ -558,12 +557,12 @@
         end;
       end;
-      rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, datoffset);
-      if CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights then
-        ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs)
-      else if CR_AppendRaw in ConManager.Connection[ConID].ChangeRights then
-        i := ConManager.Connection[ConID].AppendRawFile(rawinfo.LocSep, fs);
-        ConManager.Connection[ConID].UpdateDatFilePart(fileid, datoffset, 4, @i);
+      rawinfo := ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset);
+      if CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights then
+        ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, fs)
+      else if CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights then
+        i := ConManager.Connection[ConnectionID].AppendRawFile(rawinfo.LocSep, fs);
+        ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, datoffset, 4, @i);
     end else begin
-      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs);
+      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, fs);
     end;
     fs.Seek(0, soFromBeginning);
Index: oup/current/Tools/Template.pas
===================================================================
--- oup/current/Tools/Template.pas	(revision 111)
+++ oup/current/Tools/Template.pas	(revision 113)
@@ -153,4 +153,5 @@
     combo_extension.Items.Add('_All files_ (' +
       IntToStr(ConManager.Connection[FConnectionID].GetFileCount) + ')');
+    exts := nil;
     exts := ConManager.Connection[FConnectionID].GetExtensionsList(EF_ExtCount);
     for i := 0 to exts.Count - 1 do
@@ -177,5 +178,4 @@
   pattern: String;
   files: TStrings;
-  i: Integer;
 begin
   if FConnectionID > -1 then
@@ -192,4 +192,5 @@
         Extension := '';
 
+    files := nil;
     files := ConManager.Connection[FConnectionID].GetFilesList(extension, pattern, no_zero_bytes, FSortBy);
 
@@ -283,6 +284,4 @@
 var
   name: String;
-  nstart, nend: Integer;
-  i: Integer;
 begin
   if combo_connection.ItemIndex >= 0 then
