Index: /branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h	(revision 40782)
@@ -3,4 +3,5 @@
 int	      args		  PROTO((int *argc, char **argv));
 void          SetUpGraphic        PROTO((int *argc, char **argv));
+void          FreeGraphic         PROTO((void));
 void          DefineLayout        PROTO((int, char **));
 int	      EventLoop		  PROTO((void));
@@ -29,5 +30,4 @@
 void          MapWindow           PROTO((Graphic *graphic));
 void          CheckVisual         PROTO((Graphic *graphic, int *argc, char **argv));
-void          FreeVisual          PROTO((Graphic *graphic));
 
 /* X drawing utilities */
@@ -116,4 +116,5 @@
 
 void          InitLayout          PROTO((int argc, char **argv));
+void          FreeLayout          PROTO((void));
 
 /* PS drawing utilities */
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/CheckVisual.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/CheckVisual.c	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/CheckVisual.c	(revision 40782)
@@ -195,7 +195,2 @@
   }
 }
-
-void FreeVisual (Graphic *graphic) {
-  free (graphic[0].pixels);
-  free (graphic[0].cmap);
-}
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/Layout.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/Layout.c	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/Layout.c	(revision 40782)
@@ -45,2 +45,7 @@
   AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1);
 }
+
+void FreeLayout (void) {
+  FreeSections ();
+  FreeRotFonts ();
+}
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/LoadLabels.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/LoadLabels.c	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/LoadLabels.c	(revision 40782)
@@ -26,4 +26,6 @@
   label[Nbytes] = 0;
   
+  FREE (label);
+
   c = GetRotFont (&size);
 
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/SetUpGraphic.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/SetUpGraphic.c	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/SetUpGraphic.c	(revision 40782)
@@ -32,4 +32,6 @@
   graphic->pixels       = NULL;
 
+  graphic->smooth_sigma = 0.0;
+
   if (!USE_XWINDOW) {
     ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_STATIC);
@@ -50,6 +52,4 @@
   CheckVisual (graphic, argc, argv);
   CheckColors (graphic, argc, argv);
-
-  graphic->smooth_sigma = 0.0;
 
   icon.width = icon_width;
@@ -97,2 +97,10 @@
   return TRUE;
 }
+
+void FreeGraphic () {
+  free (graphic->pixels);
+  free (graphic->cmap);
+  free (graphic->color);
+  free (graphic->colormapName);
+  free (graphic);
+}
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawImage.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawImage.c	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawImage.c	(revision 40782)
@@ -187,6 +187,4 @@
 
   free (data);
-
-  // XDestroyImage (pix);
 }
 
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/kapa.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/kapa.c	(revision 40781)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/kapa.c	(revision 40782)
@@ -10,11 +10,11 @@
   EventLoop ();
 
-  // free things related to the graphic:
-  { 
-    Graphic *graphic = GetGraphic ();
-    FreeVisual(graphic);
-  }
-  
   CloseDisplay ();
+
+  // free things
+  FreeLayout();
+  FreeGraphic();
+  FREE (NAME_WINDOW);
+
   MemoryDumpAndExit ();
 }
