Index: trunk/cli/convert.ml
===================================================================
--- trunk/cli/convert.ml	(revision 41)
+++ trunk/cli/convert.ml	(revision 42)
@@ -27,27 +27,44 @@
 	t
 
-let acc_ref id t a =
-	Conversion.Id_map.update t (function
-	| Some s -> Some (Conversion.Ref_set.add id s)
-	| None -> Some (Conversion.Ref_set.singleton id)
-	) a
+let acc_rel source target a =
+	prerr_endline source;
+	Conversion.Id_map.update target
+	(function Some set -> Some (Conversion.Ref_set.add source set)
+		| None -> Some (Conversion.Ref_set.singleton source))
+	a
 
-let fold_refs text refs = String_set.fold (acc_ref text.Text.id) (Text.set "references" text) refs
-let fold_reps text reps = String_set.fold (acc_ref text.Text.id) (Text.set "in-reply-to" text) reps
+let empty_rels () = Conversion.Id_map.empty, Conversion.Id_map.empty
+
+let acc_txt_refs text refs = String_set.fold (acc_rel text.Text.id) (Text.set "references" text) refs
+let acc_txt_reps text reps = String_set.fold (acc_rel text.Text.id) (Text.set "in-reply-to" text) reps
+let acc_txt_rels (refs, reps) (elt, _paths) =
+	acc_txt_refs elt refs, acc_txt_reps elt reps
+
+let acc_pck_refs id refs_ls refs = String_set.fold (acc_rel id) (String_set.of_list refs_ls) refs
+let acc_pck_reps id reps_ls reps = String_set.fold (acc_rel id) (String_set.of_list reps_ls) reps
+let acc_pck_rels refs_reps peer =
+	let path = try List.hd peer.Peers.pack.Header_pack.info.locations with Failure _ -> "" in
+	try Header_pack.fold
+		(fun (refs, reps) id _t _title _authors _topics refs_ls reps_ls ->
+			let id = Filename.concat path id in
+			acc_pck_refs id refs_ls refs, acc_pck_reps id reps_ls reps)
+		refs_reps peer.Peers.pack
+	with e -> prerr_endline "acc_pck_rels"; raise e
 
 let directory converters noindex repo =
-	let fn (ts,refs,reps,ls,acc) ((elt,_) as r) =
-		Topic_set.to_map ts (Text.set "topics" elt),
-		fold_refs elt refs, fold_reps elt reps,
-		elt::ls,
-		if convert converters {repo with references = refs; replies = reps} r then acc+1 else acc in
-	let topics, references, replies, texts, count =
-		File_store.(fold ~dir:repo.Conversion.dir ~order:oldest fn
-			(Topic_set.Map.empty, Conversion.Id_map.empty, Conversion.Id_map.empty, [], 0)) in
+	let order = File_store.oldest in
+	let repo =
+		let references, replies =
+			File_store.fold ~dir:repo.Conversion.dir ~order acc_txt_rels (empty_rels ()) in
+		let references, replies = Peers.fold acc_pck_rels (references, replies) in
+		Printf.eprintf "%s %d\n" repo.Conversion.dir (Conversion.Id_map.cardinal replies);
+		{ repo with references; replies } in
+	let acc (ts,ls,acc) ((elt,_) as r) = Topic_set.to_map ts (Text.set "topics" elt), elt::ls,
+		if convert converters repo r then acc+1 else acc in
+	let topics, texts, count =
+		File_store.fold ~dir:repo.Conversion.dir ~order acc (Topic_set.Map.empty, [], 0) in
 	let topic_roots = try List.rev @@ String_set.list_of_csv (Store.KV.find "Topics" repo.kv)
 		with Not_found -> Topic_set.roots topics in
-	Printf.eprintf "%d\n" (Conversion.Id_map.cardinal replies);
-	let repo = Conversion.{ repo with
-		topic_roots; topics; references; replies; texts = List.rev texts } in
+	let repo = Conversion.{ repo with topic_roots; topics; texts = List.rev texts } in
 	if not noindex then
 		List.iter (fun c -> match c.Conversion.indices with None -> () | Some f -> f repo) converters;
@@ -79,7 +96,5 @@
 			| Ok text ->
 				let dir = "." in
-				let references, replies = File_store.(fold ~dir ~order:newest
-					(fun (refs, reps) (elt, _) -> fold_refs elt refs, fold_reps elt reps)
-					(Conversion.Id_map.empty, Conversion.Id_map.empty)) in
+				let references, replies = File_store.(fold ~dir ~order:newest acc_txt_rels (empty_rels ())) in
 				let repo = { (Conversion.empty ()) with dir; kv = load_kv ""; references; replies } in
 				ignore @@ convert (converters types repo.kv) repo (text, [path])
Index: trunk/cli/html.ml
===================================================================
--- trunk/cli/html.ml	(revision 41)
+++ trunk/cli/html.ml	(revision 42)
@@ -89,5 +89,5 @@
 		^ opt_kv "Replies:" (try
 				ref_links (Conversion.Id_map.find text.id conversion.Conversion.replies)
-				with Not_found -> "empty replies")
+				with Not_found -> "")
 		^ {|</dl></header><pre style="white-space:pre-wrap">|} in
 	wrap conversion htm text.title ((T.of_string text.body header) ^ "</pre></article>")
Index: trunk/cli/peers.ml
===================================================================
--- trunk/cli/peers.ml	(revision 41)
+++ trunk/cli/peers.ml	(revision 42)
@@ -10,5 +10,5 @@
 	let open Logarion.Peers in
 	Printf.printf "%s" peer.path;
-	List.iter (Printf.printf "\t%s\n") peer.locations
+	List.iter (Printf.printf "\t%s\n") peer.pack.info.locations
 
 let remove_repo id =
Index: trunk/cli/pull.ml
===================================================================
--- trunk/cli/pull.ml	(revision 41)
+++ trunk/cli/pull.ml	(revision 42)
@@ -76,5 +76,5 @@
 			output_string file txt; close_out file
 
-let per_text url dir filter print i id time title authors topics = match id with
+let per_text url dir filter print i id time title authors topics _refs _reps = match id with
 	| "" -> Printf.eprintf "\nInvalid id for %s\n" title
 	| id -> let open Logarion in
@@ -128,9 +128,10 @@
 	let pull got_one peer_url = if got_one then got_one else
 		(pull_index peer_url auths topics) in
+	let open Logarion in
 	let fold_locations init peer =
-		ignore @@ List.fold_left pull init peer.Logarion.Peers.locations;
+		ignore @@ List.fold_left pull init peer.Peers.pack.Header_pack.info.locations;
 		false
 	in
-	ignore @@ Logarion.Peers.fold fold_locations false;
+	ignore @@ Peers.fold fold_locations false;
 	Curl.global_cleanup ()
 
