Index: perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
===================================================================
--- perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	(revision aa0a0b55489e41bbf85f4613156df3e987972b94)
+++ perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	(revision 87894109aeedcc8ba50bd3b983c0d9558f1e6b32)
@@ -285,5 +285,5 @@
         {
             summary => "Send a Jabber Message",
-            usage   => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]"
+            usage   => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]"
         }
     );
@@ -308,6 +308,5 @@
             description => "jmuc sends Jabber commands related to MUC.\n\n"
               . "The following commands are available\n\n"
-              . "join <muc>[/<nick>]\n"
-              . "            Join a MUC (with a given nickname, or otherwise your JID).\n\n"
+              . "join <muc>  Join a MUC.\n\n"
               . "part <muc>  Part a MUC.\n"
               . "            The MUC is taken from the current message if not supplied.\n\n"
@@ -378,5 +377,6 @@
         my $cjidStr = $conn->baseJIDExists($jidStr);
         if ($cjidStr) {
-            die("Already logged in as $cjidStr.\n");
+            BarnOwl::error("Already logged in as $cjidStr.");
+            return;
         }
     }
@@ -387,9 +387,11 @@
 
     if ( !$uid || !$componentname ) {
-        die("usage: $cmd JID\n");
+        BarnOwl::error("usage: $cmd JID");
+        return;
     }
 
     if ( $conn->jidActive($jidStr) ) {
-        die("Already logged in as $jidStr.\n");
+        BarnOwl::error("Already logged in as $jidStr.");
+        return;
     } elsif ($conn->jidExists($jidStr)) {
         return $conn->tryReconnect($jidStr, 1);
@@ -524,5 +526,6 @@
 sub cmd_jlist {
     if ( !( scalar $conn->getJIDs() ) ) {
-        die("You are not logged in to Jabber.\n");
+        BarnOwl::error("You are not logged in to Jabber.");
+        return;
     }
     BarnOwl::popless_ztext( onGetBuddyList() );
@@ -531,5 +534,6 @@
 sub cmd_jwrite {
     if ( !$conn->connected() ) {
-        die("You are not logged in to Jabber.\n");
+        BarnOwl::error("You are not logged in to Jabber.");
+        return;
     }
 
@@ -539,5 +543,4 @@
     my $jwrite_thread  = "";
     my $jwrite_subject = "";
-    my $jwrite_body;
     my ($to, $from);
     my $jwrite_type    = "chat";
@@ -551,11 +554,12 @@
         'subject=s' => \$jwrite_subject,
         'account=s' => \$from,
-        'id=s'      => \$jwrite_sid,
-        'message=s' => \$jwrite_body,
+        'id=s'     =>  \$jwrite_sid,
     ) or die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
     $jwrite_type = 'groupchat' if $gc;
 
     if ( scalar @ARGV != 1 ) {
-        die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
+        BarnOwl::error(
+            "Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]");
+        return;
     }
     else {
@@ -566,5 +570,5 @@
 
     unless(scalar @candidates) {
-        die("Unable to resolve JID $to\n");
+        die("Unable to resolve JID $to");
     }
 
@@ -573,7 +577,7 @@
     unless(scalar @candidates) {
         if(!$from) {
-            die("You must specify an account with -a\n");
+            die("You must specify an account with -a");
         } else {
-            die("Unable to resolve account $from\n");
+            die("Unable to resolve account $from");
         }
     }
@@ -590,9 +594,4 @@
         type    => $jwrite_type
     };
-
-    if (defined($jwrite_body)) {
-        process_owl_jwrite($jwrite_body);
-        return;
-    }
 
     if(scalar @candidates > 1) {
@@ -632,5 +631,6 @@
     my $func = $jmuc_commands{$cmd};
     if ( !$func ) {
-        die("jmuc: Unknown command: $cmd\n");
+        BarnOwl::error("jmuc: Unknown command: $cmd");
+        return;
     }
 
@@ -654,5 +654,5 @@
         }
         else {
-            die("You must specify an account with -a <jid>\n");
+            BarnOwl::error('You must specify an account with -a <jid>');
         }
         return $func->( $jid, $muc, @ARGV );
@@ -667,5 +667,5 @@
 
     $muc = shift @ARGV
-      or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]\n");
+      or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]");
 
     die("Error: Must specify a fully-qualified MUC name (e.g. barnowl\@conference.mit.edu)\n")
@@ -680,5 +680,5 @@
                                                    MaxChars => 0
                                                   });
-    $completion_jids{$muc->GetJID('base')} = 1;
+    $completion_jids{$muc} = 1;
     return;
 }
@@ -688,10 +688,10 @@
 
     $muc = shift @args if scalar @args;
-    die("Usage: jmuc part [<muc>] [-a <account>]\n") unless $muc;
+    die("Usage: jmuc part [<muc>] [-a <account>]") unless $muc;
 
     if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) {
         queue_admin_msg("$jid has left $muc.");
     } else {
-        die("Error: Not joined to $muc\n");
+        die("Error: Not joined to $muc");
     }
 }
@@ -703,5 +703,5 @@
     $muc = shift @args if scalar @args;
 
-    die("Usage: jmuc invite <jid> [<muc>] [-a <account>]\n")
+    die('Usage: jmuc invite <jid> [<muc>] [-a <account>]')
       unless $muc && $invite_jid;
 
@@ -718,5 +718,5 @@
     my ( $jid, $muc, @args ) = @_;
     $muc = shift @args if scalar @args;
-    die("Usage: jmuc configure [<muc>]\n") unless $muc;
+    die("Usage: jmuc configure [<muc>]") unless $muc;
     my $iq = Net::Jabber::IQ->new();
     $iq->SetTo($muc);
@@ -759,5 +759,5 @@
 
     $muc = shift @args if scalar @args;
-    die("Usage: jmuc presence [<muc>]\n") unless $muc;
+    die("Usage: jmuc presence [<muc>]") unless $muc;
 
     if ($muc eq '-a') {
@@ -774,5 +774,5 @@
     else {
         my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc);
-        die("No such muc: $muc\n") unless $m;
+        die("No such muc: $muc") unless $m;
         BarnOwl::popless_ztext(jmuc_presence_single($m));
     }
@@ -801,5 +801,6 @@
     my $func = $jroster_commands{$cmd};
     if ( !$func ) {
-        die("jroster: Unknown command: $cmd\n");
+        BarnOwl::error("jroster: Unknown command: $cmd");
+        return;
     }
 
@@ -824,5 +825,5 @@
         }
         else {
-            die("You must specify an account with -a <jid>\n");
+            BarnOwl::error('You must specify an account with -a <jid>');
         }
         return $func->( $jid, $name, \@groups, $purgeGroups,  @ARGV );
@@ -848,5 +849,5 @@
     }
     else {
-        die("You must specify an account with -a <jid>\n");
+        BarnOwl::error('You must specify an account with -a <jid>');
     }
 
@@ -1233,13 +1234,4 @@
         $completion_jids{$room} = 1;
 
-        my $muc;
-        if ($dir eq 'in') {
-            my $connection = $conn->getConnectionFromSid($props{sid});
-            $muc = $connection->FindMUC(jid => $from);
-        } else {
-            my $connection = $conn->getConnectionFromJID($props{from});
-            $muc = $connection->FindMUC(jid => $to);
-        }
-        $props{from} = $muc->GetFullJID($from) || $nick || $room;
         $props{sender} = $nick || $room;
         $props{recipient} = $room;
@@ -1339,5 +1331,5 @@
         return $givenJIDStr if ($conn->jidExists($givenJIDStr) );
         return resolveConnectedJID($givenJID->GetJID('base')) if $loose;
-        die("Invalid account: $givenJIDStr\n");
+        die("Invalid account: $givenJIDStr");
     }
 
@@ -1392,5 +1384,5 @@
         # Not one of ours.
         else {
-            die("Invalid account: $givenJIDStr\n");
+            die("Invalid account: $givenJIDStr");
         }
 
@@ -1438,5 +1430,5 @@
     if($from) {
         $from_jid = resolveConnectedJID($from, 1);
-        die("Unable to resolve account $from\n") unless $from_jid;
+        die("Unable to resolve account $from") unless $from_jid;
         $to_jid = resolveDestJID($to, $from_jid);
         push @matches, [$from_jid, $to_jid] if $to_jid;
