#include "map.h" /* for Map struct */
 #include "keybindings.h" /* for KeysWinData, KeyBinding structs */
 #include "command_db.h" /* for free_command_db() */
-#include "windows.h" /* for Win struct */
-#include "wincontrol.h" /* for free_win() */
+#include "windows.h" /* for Win struct, free_win() */
 
 
 
 
 
 
 
-extern void free_win(struct Win * win)
-{
-    free(win->_title);
-    free(win);
-}
-
-
-
 extern struct Win * init_win_from_file(struct World * world, char * w_name,
                                        void (* f) (struct Win *))
 {
     exit_err(fclose(file), world, err);
 
     struct WinMeta * wmeta = world->wins.meta;
-    struct Win * w = malloc(sizeof(struct Win));
-    init_win(wmeta, w, title, height, width, world, f);
+    struct Win * wp; // = malloc(sizeof(struct Win));
+    init_win(wmeta, &wp, title, height, width, world, f);
     free(title);
-    return w;
+    return wp;
 }
 
 
 
 
 
 
-/* Free allocated memory for an initialized Win struct. */
-extern void free_win(struct Win * win);
-
-
-
-
 /* Wrapper around init_win() that reads the desired window size and title from a
  * file at the path prefixing the provided win name "w_name" with
  * "config/windows/". "f"() is the window drawing function (Win._draw()).
 
 
 
 
-extern uint8_t init_win(struct WinMeta * wmeta, struct Win * w, char * title,
+extern uint8_t init_win(struct WinMeta * wmeta, struct Win ** wp, char * title,
                         int16_t height, int16_t width,
                         void * data, void * func)
 {
+    struct Win * w = malloc(sizeof(struct Win));
+    if (NULL == w)
+    {
+        return 1;
+    }
     w->_prev             = 0;
     w->_next             = 0;
     w->frame.curses_win  = 0;
     {
         w->frame.size.y = wmeta->padframe.size.y - 1;
     }
+    *wp = w;
     return 0;
 }
 
 
 
+extern void free_win(struct Win * win)
+{
+    free(win->_title);
+    free(win);
+}
+
+
+
 extern uint8_t append_win(struct WinMeta * wmeta, struct Win * w)
 {
     if (0 != wmeta->_chain_start)
 
  *
  * Other members of the Win struct are initialized to 0.
  */
-extern uint8_t init_win(struct WinMeta * wmeta, struct Win * w, char * title,
+extern uint8_t init_win(struct WinMeta * wmeta, struct Win ** w, char * title,
                         int16_t height, int16_t width,
                         void * data, void * func);
 
 
 
+/* Free allocated memory for an initialized Win struct. */
+extern void free_win(struct Win * win);
+
+
+
 /* Append/suspend window "w" to/from chain of visible windows below "wmeta".
  * Appended windows will become active. Suspended active windows will move the
  * active window selection to their successor in the window chain or, failing