diff --git a/src/include/ZMap/zmapXRemote.h b/src/include/ZMap/zmapXRemote.h
index d2749b281c6ca8947823522e6b08f97f9e4cd6f6..29534759829970050d562203dfbdc0099c5d13ea 100755
--- a/src/include/ZMap/zmapXRemote.h
+++ b/src/include/ZMap/zmapXRemote.h
@@ -29,9 +29,9 @@
  *
  * Exported functions: See ZMap/zmapXRemote.h (this file)
  * HISTORY:
- * Last edited: Jan 17 09:10 2010 (edgrif)
+ * Last edited: Mar  2 10:44 2010 (edgrif)
  * Created: Wed Apr 13 19:02:52 2005 (rds)
- * CVS info:   $Id: zmapXRemote.h,v 1.23 2010-01-18 09:02:50 edgrif Exp $
+ * CVS info:   $Id: zmapXRemote.h,v 1.24 2010-03-03 11:01:21 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -52,10 +52,10 @@
 /* These are here just to allow checking */
 
 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
-#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.23 $"
+#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.24 $"
 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
 
-#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.23 $"
+#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.24 $"
 
 #define ZMAP_XREMOTE_CURRENT_VERSION_ATOM "_ZMAP_XREMOTE_VERSION"
 #define ZMAP_XREMOTE_APPLICATION_ATOM     "_ZMAP_XREMOTE_APP"
@@ -155,6 +155,9 @@ extern gboolean externalPerl;
 /* ================================================ */
 /* COMMON MODE METHODS */
 /* ================================================ */
+
+void zMapXRemoteSetDebug(gboolean debug_on) ;
+
 ZMapXRemoteObj zMapXRemoteNew(void);     /* This just returns the object and checks XOpenDisplay(getenv(DISPLAY)) */
 
 void zMapXRemoteSetRequestAtomName(ZMapXRemoteObj object, char *name); /* Better set in zMapXRemoteInitServer if Server though */
diff --git a/src/zmapControl/remote/zmapXRemote.c b/src/zmapControl/remote/zmapXRemote.c
index b4593c355168f10ef26473b9e25477b2ea9ac87f..3d6090dcfb39eb7c6265c9af626e13985ffc16d4 100755
--- a/src/zmapControl/remote/zmapXRemote.c
+++ b/src/zmapControl/remote/zmapXRemote.c
@@ -26,15 +26,15 @@
  *
  * Exported functions: See ZMap/zmapXRemote.h
  * HISTORY:
- * Last edited: Feb 10 16:47 2010 (edgrif)
+ * Last edited: Mar  2 10:51 2010 (edgrif)
  * Created: Wed Apr 13 19:04:48 2005 (rds)
- * CVS info:   $Id: zmapXRemote.c,v 1.44 2010-02-10 16:52:09 edgrif Exp $
+ * CVS info:   $Id: zmapXRemote.c,v 1.45 2010-03-03 11:01:21 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
 #include "zmapXRemote_P.h"
 
-gboolean externalPerl = TRUE;
+
 
 enum
   {
@@ -96,6 +96,33 @@ static void zmapXRemoteUnLock();
 static gboolean zmapXRemoteIsLocked();
 
 
+
+/* An external global which controls the two modes of the code
+ * 
+ * - compiled into ZMap
+ * 
+ * - compiled into a Perl module for otterlace to use.
+ * 
+ */
+gboolean externalPerl = TRUE ;
+
+
+/* Controls debugging output. */
+static gboolean debug_G = FALSE ;
+
+
+/* Can be called at any time and controls debugging for all instances of ZMapXRemoteObj,
+ * TRUE turns debugging on and FALSE turns it off again. */
+void zMapXRemoteSetDebug(gboolean debug_on)
+{
+  debug_G = debug_on ;
+
+  return ;
+}
+
+
+
+
 /*!
  * \brief Create a ZMapXRemoteObj handle for later use
  *
diff --git a/src/zmapControl/remote/zmapXRemote_P.h b/src/zmapControl/remote/zmapXRemote_P.h
index f9fa6e3b57ae1ed4f7738b847b2d43da68e2ce38..eae84d43ba124cbf02c6bb4250668776267bc1f0 100755
--- a/src/zmapControl/remote/zmapXRemote_P.h
+++ b/src/zmapControl/remote/zmapXRemote_P.h
@@ -26,9 +26,9 @@
  *
  * Exported functions: None
  * HISTORY:
- * Last edited: Feb 19 10:22 2010 (edgrif)
+ * Last edited: Mar  2 10:56 2010 (edgrif)
  * Created: Thu Apr 14 13:07:51 2005 (rds)
- * CVS info:   $Id: zmapXRemote_P.h,v 1.20 2010-02-19 10:23:00 edgrif Exp $
+ * CVS info:   $Id: zmapXRemote_P.h,v 1.21 2010-03-03 11:01:21 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -73,31 +73,18 @@ typedef struct
 
 /*====================== DEBUGGING =========================*/
 
-
-
-#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
-#define DO_DEBUGGING
-#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
-
-
-
-#ifdef DO_DEBUGGING
-
 extern char *ZMAP_X_PROGRAM_G ;
 
+
 #define zmapXDebug(FORMAT, ...)                           \
 G_STMT_START {                                             \
-  g_printerr("[%s] [" ZMAP_MSG_FORMAT_STRING "] " FORMAT,  \
-	     ZMAP_X_PROGRAM_G,				   \
-	     ZMAP_MSG_FUNCTION_MACRO,			   \
-	     __VA_ARGS__) ;				   \
+  if (debug_G)                                             \
+    g_printerr("[%s] [" ZMAP_MSG_FORMAT_STRING "] " FORMAT,	\
+	       ZMAP_X_PROGRAM_G,				\
+	       ZMAP_MSG_FUNCTION_MACRO,				\
+	       __VA_ARGS__) ;					\
 } G_STMT_END
 
-#else
-
-#define zmapXDebug(FORMAT, ...) do {} while(0)
-
-#endif
 /*==========================================================*/