Index: functions.c
===================================================================
--- functions.c	(revision 36486be17f6eb6298a9c9b05929fe1b6f31e065b)
+++ functions.c	(revision 24ccc01260afb7fd3aa52ade9b9bcc4e4075b504)
@@ -229,8 +229,14 @@
 {
   owl_message *m;
+  owl_zwrite zw;
+
+  owl_zwrite_create_from_line(&zw, zwriteline);
+  owl_zwrite_set_zsig(&zw, zsig);
 
   /* create the message */
   m=owl_malloc(sizeof(owl_message));
-  owl_message_create_from_zwriteline(m, zwriteline, body, zsig);
+  
+  owl_message_create_from_zwrite(m, &zw, body);
+  owl_zwrite_free(&zw);
 
   return(m);
Index: logging.c
===================================================================
--- logging.c	(revision 4542047a899dadba958a360ac1cb146c7b5a41dd)
+++ logging.c	(revision 24ccc01260afb7fd3aa52ade9b9bcc4e4075b504)
@@ -171,5 +171,5 @@
 
 
-void owl_log_outgoing_zephyr_error(const char *to, const char *text)
+void owl_log_outgoing_zephyr_error(const owl_zwrite *zw, const char *text)
 {
   FILE *file;
@@ -181,7 +181,6 @@
    * owl_log_shouldlog_message()
    */
-  zwriteline=owl_sprintf("zwrite %s", to);
-  m=owl_function_make_outgoing_zephyr(text, zwriteline, "");
-  owl_free(zwriteline);
+  m = owl_malloc(sizeof(owl_message));
+  owl_message_create_from_zwrite(m, zw, text);
   if (!owl_log_shouldlog_message(m)) {
     owl_message_free(m);
@@ -191,5 +190,5 @@
 
   /* chop off a local realm */
-  tobuff=short_zuser(to);
+  tobuff = short_zuser(owl_list_get_element(&(zw->recips), 0));
 
   /* expand ~ in path names */
Index: message.c
===================================================================
--- message.c	(revision 27f6487f535f66d854f584b81aacf02ea8da4c58)
+++ message.c	(revision 24ccc01260afb7fd3aa52ade9b9bcc4e4075b504)
@@ -898,14 +898,10 @@
 }
 
-void owl_message_create_from_zwriteline(owl_message *m, const char *line, const char *body, const char *zsig)
-{
-  owl_zwrite z;
+void owl_message_create_from_zwrite(owl_message *m, const owl_zwrite *z, const char *body)
+{
   int ret;
   char hostbuff[5000];
   
   owl_message_init(m);
-
-  /* create a zwrite for the purpose of filling in other message fields */
-  owl_zwrite_create_from_line(&z, line);
 
   /* set things */
@@ -913,17 +909,19 @@
   owl_message_set_type_zephyr(m);
   owl_message_set_sender(m, owl_zephyr_get_sender());
-  owl_message_set_class(m, owl_zwrite_get_class(&z));
-  owl_message_set_instance(m, owl_zwrite_get_instance(&z));
-  if (owl_zwrite_get_numrecips(&z)>0) {
-    char *longzuser = long_zuser(owl_zwrite_get_recip_n(&z, 0));
+  owl_message_set_class(m, owl_zwrite_get_class(z));
+  owl_message_set_instance(m, owl_zwrite_get_instance(z));
+  if (owl_zwrite_get_numrecips(z)>0) {
+    char *longzuser = long_zuser(owl_zwrite_get_recip_n(z, 0));
     owl_message_set_recipient(m,
 			      longzuser); /* only gets the first user, must fix */
     owl_free(longzuser);
   }
-  owl_message_set_opcode(m, owl_zwrite_get_opcode(&z));
-  owl_message_set_realm(m, owl_zwrite_get_realm(&z)); /* also a hack, but not here */
-  owl_message_set_zwriteline(m, line);
+  owl_message_set_opcode(m, owl_zwrite_get_opcode(z));
+  owl_message_set_realm(m, owl_zwrite_get_realm(z)); /* also a hack, but not here */
+  if(z->zwriteline) {
+    owl_message_set_zwriteline(m, z->zwriteline);
+  }
   owl_message_set_body(m, body);
-  owl_message_set_zsig(m, zsig);
+  owl_message_set_zsig(m, owl_zwrite_get_zsig(z));
   
   /* save the hostname */
@@ -937,9 +935,7 @@
 
   /* set the "isprivate" attribute if it's a private zephyr. */
-  if (owl_zwrite_is_personal(&z)) {
+  if (owl_zwrite_is_personal(z)) {
     owl_message_set_isprivate(m);
   }
-
-  owl_zwrite_free(&z);
 }
 
Index: owl.h
===================================================================
--- owl.h	(revision 0e5afa2bbf43713baa4056d267c8f99c4104238a)
+++ owl.h	(revision 24ccc01260afb7fd3aa52ade9b9bcc4e4075b504)
@@ -314,4 +314,5 @@
 
 typedef struct _owl_zwrite {
+  char *zwriteline;
   char *class;
   char *inst;
Index: zephyr.c
===================================================================
--- zephyr.c	(revision 36486be17f6eb6298a9c9b05929fe1b6f31e065b)
+++ zephyr.c	(revision 24ccc01260afb7fd3aa52ade9b9bcc4e4075b504)
@@ -769,4 +769,7 @@
     } else {
       char buff[BUFFLEN];
+      owl_zwrite zw;
+      char *realm;
+
       tmp = short_zuser(retnotice->z_recipient);
       owl_function_error("%s: Not logged in or subscribing.", tmp);
@@ -796,5 +799,22 @@
       }
       owl_function_adminmsg("", buff);
-      owl_log_outgoing_zephyr_error(tmp, buff);
+
+      memset(&zw, 0, sizeof(zw));
+      zw.class = owl_strdup(retnotice->z_class);
+      zw.inst  = owl_strdup(retnotice->z_class_inst);
+      realm = strchr(retnotice->z_recipient, '@');
+      if(realm) {
+        zw.realm = owl_strdup(realm + 1);
+      } else {
+        zw.realm = owl_strdup(owl_zephyr_get_realm());
+      }
+      zw.opcode = owl_strdup(retnotice->z_opcode);
+      zw.zsig   = owl_strdup("");
+      owl_list_create(&(zw.recips));
+      owl_list_append_element(&(zw.recips), owl_strdup(tmp));
+
+      owl_log_outgoing_zephyr_error(&zw, buff);
+
+      owl_zwrite_free(&zw);
       owl_free(tmp);
     }
Index: zwrite.c
===================================================================
--- zwrite.c	(revision 36486be17f6eb6298a9c9b05929fe1b6f31e065b)
+++ zwrite.c	(revision 24ccc01260afb7fd3aa52ade9b9bcc4e4075b504)
@@ -24,4 +24,5 @@
   z->noping=0;
   owl_list_create(&(z->recips));
+  z->zwriteline = owl_strdup(line);
 
   /* parse the command line for options */
@@ -350,4 +351,10 @@
 }
 
+void owl_zwrite_set_zsig(owl_zwrite *z, const char *zsig)
+{
+  if(z->zsig) owl_free(z->zsig);
+  z->zsig = owl_strdup(zsig);
+}
+
 void owl_zwrite_get_recipstr(const owl_zwrite *z, char *buff)
 {
@@ -390,4 +397,5 @@
 {
   owl_list_free_all(&(z->recips), &owl_free);
+  if (z->zwriteline) owl_free(z->zwriteline);
   if (z->class) owl_free(z->class);
   if (z->inst) owl_free(z->inst);
