diff --git a/dotter.c b/dotter.c
index ddd5c67427122a72ad45404c3a970e7713f68b9c..8d8f1bf21e0350f82798e04a238c89cd78701044 100644
--- a/dotter.c
+++ b/dotter.c
@@ -29,7 +29,7 @@
  * * Mar 17 16:24 1999 (edgrif): Fixed bug which crashed xace when a
  *              negative alignment length was given.
  * Created: Wed Mar 17 16:23:21 1999 (edgrif)
- * CVS info:   $Id: dotter.c,v 1.12 2010-08-31 15:30:55 gb10 Exp $
+ * CVS info:   $Id: dotter.c,v 1.13 2010-08-31 15:46:31 gb10 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -1769,7 +1769,8 @@ static void YdrawSEGxy(MSP *msp, float offset)
 
 static int isHorizontalMSP(MSP *msp) {
 
-    if (!msp->qname) messcrash("No qname set in MSP - I need this to associate it with one of the sequences");
+    if (!msp->qname)
+      g_error("No qname set in MSP - I need this to associate it with one of the sequences");
 
     if (!strcasecmp(msp->qname, qname) || !strcmp(msp->qname, "@1"))
         return 1;
@@ -1780,7 +1781,8 @@ static int isHorizontalMSP(MSP *msp) {
 
 static int isVerticalMSP(MSP *msp) {
 
-    if (!msp->qname) messcrash("No qname set in MSP - I need this to associate it with one of the sequences");
+    if (!msp->qname) 
+      g_error("No qname set in MSP - I need this to associate it with one of the sequences");
 
     if (!strcasecmp(msp->qname, sname) || !strcmp(msp->qname, "@2"))
         return 1;
diff --git a/dotterKarlin.c b/dotterKarlin.c
index bb5c2c05ce894bdfbda4bf66ba9365d5afc3fcf1..837154a1554ea53dfe0335ec5e200ef9a83c9756 100644
--- a/dotterKarlin.c
+++ b/dotterKarlin.c
@@ -1,5 +1,5 @@
 /*  Last edited: Oct 26 10:45 2003 (edgrif) */
-/* $Id: dotterKarlin.c,v 1.2 2010-08-31 15:30:55 gb10 Exp $ */
+/* $Id: dotterKarlin.c,v 1.3 2010-08-31 15:46:31 gb10 Exp $ */
 
 /*
  -------------------------------------------------------------
@@ -31,11 +31,8 @@
 
 */
 
-#include <ctype.h>
-#include "regular.h"
-#include "graph.h"
-#include "gex.h"
 #include "dotter_.h"
+#include <gtk/gtk.h>
 
 
 #define MAXIT 20	/* Maximum number of iterations used in calculating K */
diff --git a/dotterMain.c b/dotterMain.c
index 05feec759c10597bf0075ae9333ccf6d99372136..1545dfdc31bf26ce8ae8e4f1f5c9cac3e26e436f 100644
--- a/dotterMain.c
+++ b/dotterMain.c
@@ -26,7 +26,7 @@
  * HISTORY:
  * Last edited: Aug 26 15:42 2009 (edgrif)
  * Created: Thu Aug 26 17:17:30 1999 (fw)
- * CVS info:   $Id: dotterMain.c,v 1.12 2010-08-31 15:30:55 gb10 Exp $
+ * CVS info:   $Id: dotterMain.c,v 1.13 2010-08-31 15:46:31 gb10 Exp $
  *-------------------------------------------------------------------
  */
 
@@ -237,11 +237,6 @@ static char* getUsageText()
 
 int main(int argc, char **argv)
 {
-  /* Set the message handlers */
-  g_log_set_default_handler(defaultMessageHandler, NULL);
-  g_log_set_handler(NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL, popupMessageHandler, NULL);
-
-
   DotterOptions options = {0, 0, 0, UNSET_INT, UNSET_INT, 0, 0, 1, 0, 0, 0.0, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
   
   char   
@@ -570,7 +565,7 @@ int main(int argc, char **argv)
           }
 	else if(!(file = fopen(options.FSfilename, "r")))
           {
-	    messcrash("Cannot open %s\n", options.FSfilename);
+	    g_error("Cannot open %s\n", options.FSfilename);
           }
 	
         GList *seqList = NULL; /* parser compiles a list of BlxSequences into here; not required for dotter */
@@ -625,6 +620,11 @@ int main(int argc, char **argv)
 
     if (!options.savefile)
       {
+        /* Set the message handlers. (Do this here because we don't want graphical dialog
+         * boxes for batch mode.) */
+        g_log_set_default_handler(defaultMessageHandler, NULL);
+        g_log_set_handler(NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL, popupMessageHandler, NULL);
+        
 	dotter(type, opts, options.qname, qseq, options.qoffset, options.sname, sseq, options.soffset, 
 	       0, 0, options.savefile, options.loadfile, options.mtxfile, options.memoryLimit, 
                options.dotterZoom, MSPlist, 0, options.winsize, options.pixelFacset) ;
@@ -635,12 +635,7 @@ int main(int argc, char **argv)
       }
     else
       {
-	/* stop graphical dialog boxes in batch mode. */
-	struct messContextStruct nullContext = { NULL, NULL };
-	messOutRegister(nullContext);
-	messErrorRegister (nullContext);
-	messExitRegister(nullContext);
-	messCrashRegister (nullContext);
+        /* Batch mode */
 	dotter(type, opts, options.qname, qseq, options.qoffset, options.sname, sseq, options.soffset, 
 	       0, 0, options.savefile, options.loadfile, options.mtxfile, options.memoryLimit, 
                options.dotterZoom, MSPlist, 0, options.winsize, options.pixelFacset);