diff -uNr ../mldonkey2/src/daemon/common/commonTypes.ml ./src/daemon/common/commonTypes.ml
--- ../mldonkey2/src/daemon/common/commonTypes.ml	2012-07-01 09:18:35.818807737 +0200
+++ ./src/daemon/common/commonTypes.ml	2012-07-01 10:11:47.566769055 +0200
@@ -212,6 +212,7 @@
     let uids = ref [] in
     let name = ref "" in
     let size = ref None in
+    let trackers = ref [] in
     let each k v =
       match String2.split k '.' with
       | "xt"::_ -> uids := Uid.of_string v :: !uids
@@ -221,7 +222,7 @@
       | "xs"::_ -> () (* eXtra source *)
       | "mt"::_ -> () (* manifest topic: url or urn, see http://rakjar.de/gnuticles/MAGMA-Specsv22.txt *)
       | "kt"::_ -> () (* keywords topic *)
-      | "tr"::_ -> () (* BT tracker *)
+      | "tr"::_ -> trackers := Url.decode v :: !trackers
       | "x"::_ -> () (* extensions *)
 (*
       | _ when v = "" ->
@@ -235,7 +236,12 @@
       try each k v
       with exn -> lprintf_nl "MAGNET: field %S=%S, exn %s" k v (Printexc2.to_string exn)
     ) url.Url.args;
-    object method name = !name method size = !size method uids = List.map Uid.to_uid (Uid.expand !uids) end
+    object
+      method name = !name
+      method size = !size
+      method uids = List.map Uid.to_uid (Uid.expand !uids)
+      method trackers = !trackers
+    end
   else 
     raise Not_found
 
diff -uNr ../mldonkey2/src/networks/bittorrent/bTClients.ml ./src/networks/bittorrent/bTClients.ml
--- ../mldonkey2/src/networks/bittorrent/bTClients.ml	2012-07-01 09:18:35.818807749 +0200
+++ ./src/networks/bittorrent/bTClients.ml	2012-07-01 10:03:07.410776309 +0200
@@ -103,54 +103,6 @@
 open BTUdpTracker
 open UdpSocket
 
-
-(* some stupid temporary copypasta because i couldnt figure out how to import from btinteractive *)
-(* let hack_op_file_cancel file = *)
-(*   CommonSwarming.remove_swarmer file.file_swarmer; *)
-(*   file.file_swarmer <- None; *)
-(*    (\* forward declarations turned out difficult. wtf?*\) *)
-(*   (\* file_stop file;*\) *)
-(*   remove_file file; *)
-(*   (\*disconnect_clients file;*\) *)
-(*   (\*remove_all_clients file;*\) *)
-(*   if Sys.file_exists file.file_torrent_diskname then Sys.remove file.file_torrent_diskname *)
-
-let load_torrent_string s user group =
-  if !verbose then lprintf_nl "load_torrent_string";
-  let file_id, torrent = BTTorrent.decode_torrent s in
-
-  (* Save the torrent, because we later want to put
-     it in the seeded directory. *)
-  let torrent_diskname = CommonFile.concat_file downloads_directory (torrent.torrent_name ^ ".torrent") in
-  if Sys.file_exists torrent_diskname then
-    begin
-      if !verbose then lprintf_nl "load_torrent_string: %s already exists, ignoring" torrent_diskname;
-      raise (Torrent_already_exists torrent.torrent_name)
-    end;
-  File.from_string torrent_diskname s;
-
-  if !verbose then
-    lprintf_nl "Starting torrent download with diskname: %s"
-        torrent_diskname;
-  let file = new_download file_id torrent torrent_diskname user group in
-  (* talk_to_tracker file true; TODO stupid fwd declaration issue. OTOH bep9 torrents arent tracker based anyway*)
-  CommonInteractive.start_download (file_find (file_num file));
-  file
-
-let load_torrent_file filename user group =
-  if !verbose then
-    lprintf_nl "load_torrent_file %s" filename;
-  let s = File.to_string filename in
-  (* Delete the torrent if it is in the downloads dir. because it gets saved
-     again under the torrent name and we don't want to clutter up this dir. .*)
-  if Sys.file_exists filename
-      && (Filename.dirname filename) = downloads_directory then
-    Sys.remove filename;
-  ignore (load_torrent_string s user group)
-(* end copypasta *)
-
-
-
 let string_of_event = function
   | READ_DONE -> "READ_DONE"
   | WRITE_DONE -> "WRITE_DONE"
@@ -621,9 +573,7 @@
 *)
 
 let send_bitfield c =
-  if c.client_file.file_metadata_downloading then
-    lprintf_nl "dont send bitmap, we are in metadata state"
-  else
+  if not c.client_file.file_metadata_downloading then
   send_client c (BitField
       (
       match c.client_file.file_swarmer with
@@ -667,7 +617,6 @@
   let msg = (B.encode (B.Dictionary [(* "e",B.Int 0L; *)
                                      "m", (B.Dictionary ["ut_metadata", B.Int 1L]);
                                      (* "metadata_size", B.Int (-1L) *)])) in begin
-    lprintf_file_nl (as_file file) "send extended handshake msg %s" msg;
     send_client c (Extended (Int64.to_int 0L, msg));
   end
 
@@ -675,7 +624,6 @@
   let module B = Bencode in
   let msg = (B.encode (B.Dictionary ["msg_type", B.Int 0L; (* 0 is request subtype*)
                                      "piece", B.Int piece; ])) in begin
-    lprintf_file_nl (as_file file) "send extended request for piece:%Ld msgid:%Ld msg:%s" piece c.client_ut_metadata_msg msg;
     send_client c (Extended (Int64.to_int c.client_ut_metadata_msg, msg));
   end
 
@@ -1043,7 +991,7 @@
   @param msg The message sent by the client
 *)
 and client_to_client c sock msg =
-  (* if !verbose_msg_clients then begin *)
+  if !verbose_msg_clients then begin
       let (ip,port) = (TcpBufferedSocket.peer_addr sock) in
       let (timeout, next) = get_rtimeout sock in
       lprintf_nl "CLIENT %d(%s:%d): (%d, %d,%d) Received %s"
@@ -1052,7 +1000,7 @@
       (int_of_float timeout)
       (int_of_float next)
       (TcpMessages.to_string msg);
-    (* end; *)
+  end;
 
   let file = c.client_file in
 
@@ -1154,11 +1102,9 @@
 
     | BitField p ->
         (*A bitfield is a summary of what a client have*)
-      lprintf_file_nl (as_file file) "Bitfield message,  metadata state %B" c.client_file.file_metadata_downloading ;
-      if c.client_file.file_metadata_downloading then
-        lprintf_file_nl (as_file file) "ignoring Bitfield message, we are in metadata state"
-      else
-
+      if !verbose_msg_clients then
+        lprintf_file_nl (as_file file) "Bitfield message,  metadata state %B" c.client_file.file_metadata_downloading;
+      if not c.client_file.file_metadata_downloading then
         begin
           match c.client_file.file_swarmer with
             None -> ()
@@ -1205,9 +1151,7 @@
 
     | Have n ->
         (* A client can send a "Have" without sending a Bitfield *)
-        if c.client_file.file_metadata_downloading then
-          lprintf_file_nl (as_file file)  "ignoring Have message, we are in metadata state"
-        else
+        if not c.client_file.file_metadata_downloading then
         begin
           match c.client_file.file_swarmer with
             None -> ()
@@ -1343,25 +1287,30 @@
            this should of course be moved but I dont know where yet.
            also we shouldnt send more than one handshake of course...
         *)
-        lprintf_file_nl (as_file file) "Got extended msg: %d %s" extmsg payload;
+        if !verbose_msg_clients then
+          lprintf_file_nl (as_file file) "Got extended msg: %d %s" extmsg (String.escaped payload);
 
         match extmsg with
             0x0 ->
-            lprintf_file_nl (as_file file) "Got extended handshake ";
+            if !verbose_msg_clients then
+              lprintf_file_nl (as_file file) "Got extended handshake";
             let dict = Bencode.decode payload in begin
               match dict with
                   Dictionary list ->
                     List.iter (fun (key,value) ->
                       match key, value with
                           "metadata_size", Int n ->
-                            lprintf_file_nl (as_file file) "Got metadata size %Ld" n;
+                            if !verbose_msg_clients then
+                              lprintf_file_nl (as_file file) "Got metadata size %Ld" n;
                             c.client_file.file_metadata_size <- n;
                         | "m", Dictionary  mdict ->
-                          lprintf_file_nl (as_file file) "Got meta dict ";
+                          if !verbose_msg_clients then
+                            lprintf_file_nl (as_file file) "Got meta dict";
                           List.iter (fun (key,value) ->
                             match key, value with
                                 "ut_metadata", Int n ->
-                                  lprintf_file_nl (as_file file) "ut_metadata is %Ld " n;
+                                  if !verbose_msg_clients then
+                                    lprintf_file_nl (as_file file) "ut_metadata is %Ld " n;
                                   c.client_ut_metadata_msg <- n;
                               | _ -> ();
                           ) mdict;
@@ -1390,7 +1339,8 @@
                        after the dict comes the actual piece
                        
                     *)
-            lprintf_file_nl (as_file file) "Got extended ut_metadata message ";
+            if !verbose_msg_clients then
+              lprintf_file_nl (as_file file) "Got extended ut_metadata message";
             let dict = Bencode.decode payload in
             let msgtype = ref 0L in begin
               begin
@@ -1399,13 +1349,16 @@
                       List.iter (fun (key,value) ->
                         match key, value with
                             "msg_type", Int n ->
-                              lprintf_file_nl (as_file file) "msg_type %Ld" n;
+                              if !verbose_msg_clients then
+                                lprintf_file_nl (as_file file) "msg_type %Ld" n;
                               msgtype := n;
                           | "piece", Int n ->
-                            lprintf_file_nl (as_file file) "piece %Ld" n;
+                            if !verbose_msg_clients then
+                              lprintf_file_nl (as_file file) "piece %Ld" n;
                             file.file_metadata_piece <- n;
                           | "total_size", Int n ->
-                            lprintf_file_nl (as_file file) "total_size %Ld" n; (* should always be the same as received in the initial handshake i suppose *)
+                             if !verbose_msg_clients then
+                              lprintf_file_nl (as_file file) "total_size %Ld" n; (* should always be the same as received in the initial handshake i suppose *)
                           |_ -> () ;
                       ) list;
                   |_ -> () ;
@@ -1413,18 +1366,21 @@
               match !msgtype with
                   1L ->
                     let last_piece_index = (Int64.div file.file_metadata_size 16384L) in
-                    lprintf_file_nl (as_file file) "handling metadata piece %Ld of %Ld"
-                      file.file_metadata_piece
-                      last_piece_index;
+                    if !verbose_msg_clients then
+                      lprintf_file_nl (as_file file) "handling metadata piece %Ld of %Ld"
+                        file.file_metadata_piece
+                        last_piece_index;
                         (* store the metadata piece in memory *)
                     file.file_metadata_chunks.(1 + (Int64.to_int file.file_metadata_piece)) <- payload;
                         (* possibly write metadata to disk *)
                     if file.file_metadata_piece >=
                       (Int64.div file.file_metadata_size 16384L) then begin
-                        lprintf_file_nl (as_file file) "this was the last piece ";
+                        if !verbose_msg_clients then
+                          lprintf_file_nl (as_file file) "this was the last piece";
                             (* here we should simply delete the current download, and wait for mld to pick up the new torrent file *)
                             (* the entire payload is currently in the array, TODO *)
-                        let newtorrentfile = (Printf.sprintf "/tmp/BT-%s.torrent"
+                        let newtorrentfile = (Printf.sprintf "%s/BT-%s.torrent"
+                                                      (Filename2.temp_dir_name ())
                                                       (Sha1.to_string file.file_id)) in
                         let fd = Unix32.create_rw  newtorrentfile  in
                         let fileindex = ref 0L in
@@ -1447,39 +1403,46 @@
                             ) file.file_metadata_chunks;
                           with e -> begin
                             (* TODO ignoring errors for now, the array isnt really set up right anyway yet *)
+                            (*
                             lprintf_file_nl (as_file file) "Error %s saving metadata"
                               (Printexc2.to_string e)
+                            *) ()
                           end;
                           (* Yay, now the new torrent is on disk! amazing! However, now we need to kill the dummy torrent
                              and restart it with the fresh real torrent *)
 
                           (* it seems we need to use the dynamic interface... *)
-                          lprintf_file_nl (as_file file) "cancelling metadata download ";
+                          if !verbose then
+                            lprintf_file_nl (as_file file) "cancelling metadata download ";
                           let owner = file.file_file.impl_file_owner in
                           let group = file.file_file.impl_file_group in begin
                             CommonInteractive.file_cancel (as_file file) owner ;
                             (* hack_op_file_cancel c.client_file;   *)
-                            lprintf_file_nl (as_file file) "starting download from metadata torrent %s" newtorrentfile  ;
-                            load_torrent_file newtorrentfile owner group;
+                            if !verbose then
+                              lprintf_file_nl (as_file file) "starting download from metadata torrent %s" newtorrentfile  ;
+                            ignore(CommonNetwork.network_parse_url BTGlobals.network newtorrentfile owner group);
                           end;
+                          (try Sys.remove newtorrentfile with _ -> ())
                         end;
-                        
+
                       end
                     else begin
                           (* now ask for the next metadata piece, if any *)
                       let module B = Bencode in
                       let nextpiece = (Int64.succ file.file_metadata_piece) in begin
-                        lprintf_file_nl (as_file file) "asking for the next piece %Ld" nextpiece;
+                        if !verbose_msg_clients then
+                          lprintf_file_nl (as_file file) "asking for the next piece %Ld" nextpiece;
                         send_extended_piece_request c nextpiece file;
                       end;
                     end;
                 |_ ->
-                  lprintf_file_nl (as_file file) "unmatched extended subtype" ;
+                  if !verbose_msg_clients then
+                    lprintf_file_nl (as_file file) "unmatched extended subtype" ;
             end;
 
-            
           | _ ->
-            lprintf_file_nl (as_file file) "Got extended other msg ";
+            if !verbose_msg_clients then
+              lprintf_file_nl (as_file file) "Got extended other msg ";
       end;
 
     | DHT_Port port ->
diff -uNr ../mldonkey2/src/networks/bittorrent/bTInteractive.ml ./src/networks/bittorrent/bTInteractive.ml
--- ../mldonkey2/src/networks/bittorrent/bTInteractive.ml	2012-07-01 09:18:35.818807749 +0200
+++ ./src/networks/bittorrent/bTInteractive.ml	2012-07-01 09:53:21.650783139 +0200
@@ -900,6 +900,46 @@
   String.sub text a (b - a)
 
 let op_network_parse_url url user group =
+        let exn_catch f x = try `Ok (f x) with exn -> `Exn exn in
+        match exn_catch parse_magnet_url url with
+          | `Ok magnet ->
+            (
+            if !verbose then begin
+              lprintf_nl "Got magnet url %S" url;
+              List.iter (fun(v) -> lprintf_nl "magnet %s" (string_of_uid v)) magnet#uids;
+              List.iter (fun(v) -> lprintf_nl "magnet trackers %s" v) magnet#trackers;
+            end;
+            match List2.filter_map (function BTUrl btih -> Some btih | _ -> None) magnet#uids with
+              | [] -> "No btih found in magnet url", false;
+              | btih::_ ->
+                if !verbose then
+                  lprintf_nl "Got btih %S" (Sha1.to_string btih);
+                let hashstr = (Sha1.to_string btih) in 
+                let torrent = {
+                  torrent_name = hashstr; (*magnet#name*)
+                  torrent_filename = hashstr;
+                  torrent_name_utf8 = hashstr;
+                  torrent_comment = "";
+                  torrent_pieces = Array.of_list [];  
+                  torrent_piece_size = 1L;  
+                  torrent_files = []; 
+                  torrent_length = 1L;
+                  torrent_created_by = ""; 
+                  torrent_creation_date = 1000000L;
+                  torrent_modified_by = ""; 
+                  torrent_encoding = ""; 
+                  torrent_private = false; 
+                  torrent_announce =
+                    (match magnet#trackers with
+                     | h::q -> h
+                     | [] -> "");
+                  torrent_announce_list = magnet#trackers;
+                }  in
+                ignore(new_download ~metadata:true btih torrent "" user group);
+                magnet#name, true; 
+              )
+          | `Exn _ ->
+  (
   let location_regexp = "Location: \\(.*\\)" in
   try
     let real_url = get_regexp_string url (Str.regexp location_regexp) in
@@ -966,6 +1006,7 @@
        let s = Printf.sprintf "Can not load load torrent file: %s"
          (Printexc2.to_string e) in
        s, false
+  )
 
 let op_client_info c =
   check_client_country_code c;
@@ -1280,45 +1321,6 @@
       _s ""
     ),  "<hash> :\t\t\tstart BT download using a hash DEBUG will go away";
 
-    "startbtmagnet", "Network/Bittorrent", Arg_one (fun magneturl o ->
-      begin
-        let exn_catch f x = try `Ok (f x) with exn -> `Exn exn in
-        match exn_catch parse_magnet_url magneturl with
-          | `Exn _ -> "Not a magnet url", false
-          | `Ok magnet ->
-            if !verbose then
-              lprintf_nl "Got magnet url %S" magneturl;
-            List.iter (fun(v) -> lprintf_nl "magnet %s" (string_of_uid v)) magnet#uids ;
-            match List2.filter_map (function BTUrl btih -> Some btih | _ -> None) magnet#uids with
-              | [] -> "No btih found in magnet url", false;
-              | btih::_ ->
-                lprintf_nl "Got btih %S" (Sha1.to_string btih);
-                let hashstr = (Sha1.to_string btih) in 
-                let torrent =          {
-                  torrent_name = hashstr; (*magnet#name*)
-                  torrent_filename = hashstr;
-                  torrent_name_utf8 = hashstr;
-                  torrent_comment = "";
-                  torrent_pieces = Array.of_list [];  
-                  torrent_piece_size = 1L;  
-                  torrent_files = []; 
-                  torrent_length = 1L;
-                  torrent_created_by = ""; 
-                  torrent_creation_date = 1000000L;
-                  torrent_modified_by = ""; 
-                  torrent_encoding = ""; 
-                  torrent_private = false; 
-                  torrent_announce = "";
-                  torrent_announce_list = [];
-                }  in
-                new_download ~metadata:true btih torrent "" o.conn_user.ui_user o.conn_user.ui_user.user_default_group;
-                magnet#name, true; 
-      end;
-      _s ""
-    ),  "<magneturl> :\t\t\tstart BT download using a bt magnet url DEBUG will go away";
-    
-
-    
     "stop_all_bt", "Network/Bittorrent", Arg_none (fun o ->
       List.iter (fun file -> BTClients.file_stop file ) !current_files;
       let buf = o.conn_buf in
