end
   
   def draw_minibuf opts={}
+    m = nil
     @minibuf_mutex.synchronize do
       m = @minibuf_stack.compact
       m << @flash if @flash
       m << "" if m.empty?
-
-      Ncurses.mutex.lock unless opts[:sync] == false
-      Ncurses.attrset Colormap.color_for(:none)
-      m.each_with_index do |s, i|
-        Ncurses.mvaddstr Ncurses.rows - i - 1, 0, s + (" " * [Ncurses.cols - s.length, 0].max)
-      end
     end
 
+    Ncurses.mutex.lock unless opts[:sync] == false
+    Ncurses.attrset Colormap.color_for(:none)
+    m.each_with_index do |s, i|
+      Ncurses.mvaddstr Ncurses.rows - i - 1, 0, s + (" " * [Ncurses.cols - s.length, 0].max)
+    end
     Ncurses.refresh if opts[:refresh]
     Ncurses.mutex.unlock unless opts[:sync] == false
   end
 
   def port; @parsed_uri.port || (ssl? ? 993 : 143); end
   def mailbox
     x = @parsed_uri.path[1..-1]
-    x.empty? ? 'INBOX' : x
+    x.nil? || x.empty? ? 'INBOX' : x
   end
   def ssl?; @parsed_uri.scheme == 'imaps' end
 
 
     begin
       retries = 0
       connect
-      MBox::debug "sending command: #{cmd.inspect}"
+      # MBox::debug "sending command: #{cmd.inspect}"
       begin
         result = @shell.send_command cmd
         raise SSHFileError, "Failure during remote command #{cmd.inspect}: #{(result.stderr || result.stdout || "")[0 .. 100]}" unless result.status == 0