diff --git a/ekg/themes.c b/ekg/themes.c
index abcf502..859f714 100644
--- a/ekg/themes.c
+++ b/ekg/themes.c
@@ -22,6 +22,9 @@
 #include "ekg2-config.h"
 
 #define _XOPEN_SOURCE 600
+
+#include <glib.h>
+
 #include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/ekg/windows.h b/ekg/windows.h
index 8166511..eaee17f 100644
--- a/ekg/windows.h
+++ b/ekg/windows.h
@@ -23,6 +23,8 @@
 
 #include "ekg2-config.h"
 
+#include <glib.h>
+
 #include "commands.h"
 #include "dynstuff.h"
 #include "sessions.h"
@@ -70,8 +72,6 @@ typedef enum {
 } winact_t;
 
 typedef struct window {
-	struct window *next;
-
 	unsigned short id;		/* numer okna */
 	char *target;			/* nick query albo inna nazwa albo NULL */
 	char *alias;			/* name for display */
@@ -107,7 +107,7 @@ typedef struct window {
 
 #ifndef EKG2_WIN32_NOFUNCTION
 
-extern window_t *windows;
+extern GSList *windows;
 extern window_t *window_debug;
 extern window_t *window_status;
 extern window_t *window_current;
diff --git a/plugins/httprc_xajax/httprc_xajax.c b/plugins/httprc_xajax/httprc_xajax.c
index b1453f6..87cc287 100644
--- a/plugins/httprc_xajax/httprc_xajax.c
+++ b/plugins/httprc_xajax/httprc_xajax.c
@@ -610,7 +610,8 @@ WATCHER(http_watch_read) {
 		} else {
 			char *temp;
 			int i, j;
-			window_t *w = window_current, *w2;
+			window_t *w = window_current;
+			GSList *wlist;
 			ncurses_window_t *n;
 
 			/* if user is making a refresh, we must clear collected events
@@ -660,7 +661,8 @@ WATCHER(http_watch_read) {
 			string_append (htheader, itoa(window_current->id));
 			string_append (htheader, ";\n");
 
-			for (w2 = windows; w2; w2 = w2->next) {
+			for (wlist = windows; wlist; wlist = wlist->next) {
+				window_t *w2 = wlist->data;
 				char *tempdata;
 				if (w2 == window_current)
 					string_append_format(htheader, "gwins[%d] = new Array(2, \"%s\", new Array());\n ", w2->id, window_target(w2));
diff --git a/plugins/irc/autoacts.c b/plugins/irc/autoacts.c
index 09c699c..fdb0f54 100644
--- a/plugins/irc/autoacts.c
+++ b/plugins/irc/autoacts.c
@@ -147,7 +147,7 @@ static TIMER(irc_autorejoin_timer) {
 int irc_autorejoin(session_t *s, int when, char *chan) {
 	irc_private_t *j;
 	string_t st;
-	window_t *w;
+	GSList *wlist;
 	char *chanprefix;
 	int rejoin;
 
@@ -164,7 +164,9 @@ int irc_autorejoin(session_t *s, int when, char *chan) {
 	switch (when) {
 		case IRC_REJOIN_CONNECT:
 			st = string_init(NULL);
-			for (w = windows; w; w = w->next) {
+			for (wlist = windows; wlist; wlist = wlist->next) {
+				window_t *w = wlist->data;
+
 				if (!w->target || w->session != s)			/* check if sessions match and has w->target */
 					continue;
 
diff --git a/plugins/jabber/jabber.c b/plugins/jabber/jabber.c
index 22ed9ee..cfeaabf 100644
--- a/plugins/jabber/jabber.c
+++ b/plugins/jabber/jabber.c
@@ -442,10 +442,10 @@ void jabber_handle_disconnect(session_t *s, const char *reason, int type) {
 	j->parser = NULL;
 
 	{
-		window_t *wl;
+		GSList *wlist;
 
-		for (wl = windows; wl; wl = wl->next) {
-			window_t *w = wl;
+		for (wlist = windows; wlist; wlist = wlist->next) {
+			window_t *w = wlist->data;
 
 			if (w->session == s) {
 				const char *tmp = get_uid(s, w->target);
diff --git a/plugins/logs/main.c b/plugins/logs/main.c
index 867f3ec..97465bd 100644
--- a/plugins/logs/main.c
+++ b/plugins/logs/main.c
@@ -1166,9 +1166,11 @@ static QUERY(logs_handler_newwin) {
 }
 
 static QUERY(logs_postinit) {
-	window_t *w;
-	for (w = windows; w; w = w->next)
+	GSList *wlist;
+	for (wlist = windows; wlist; wlist = wlist->next) {
+		window_t *w = wlist->data;
 		logs_window_new(w);
+	}
 	return 0;
 }
 
diff --git a/plugins/remote/remote.c b/plugins/remote/remote.c
index c255117..b15b2b8 100644
--- a/plugins/remote/remote.c
+++ b/plugins/remote/remote.c
@@ -485,7 +485,7 @@ static WATCHER_LINE(rc_input_handler_line) {
 			remote_writefd(fd, "+FORMAT", NULL);
 
 		} else if (!xstrcmp(cmd, "REQBACKLOGS")) {
-			window_t *w;
+			GSList *wlist;
 			int req_ok = 0;
 
 			/* XXX, uniknac duplikowania kodu... */
@@ -496,7 +496,8 @@ static WATCHER_LINE(rc_input_handler_line) {
 
 					req_ok = 1;
 
-					for (w = windows; w; w = w->next) {
+					for (wlist = windows; wlist; wlist = wlist->next) {
+						window_t *w = wlist->data;
 						remote_window_t *n = w->priv_data;
 						int from;
 						int i;
@@ -520,7 +521,8 @@ static WATCHER_LINE(rc_input_handler_line) {
 
 					req_ok = 1;
 
-					for (w = windows; w; w = w->next) {
+					for (wlist = windows; wlist; wlist = wlist->next) {
+						window_t *w = wlist->data;
 						remote_window_t *n = w->priv_data;
 						int i;
 
@@ -535,7 +537,8 @@ static WATCHER_LINE(rc_input_handler_line) {
 				}
 			}
 			if (req_ok == 0) {	/* jesli requet nie byl przetwarzany, to wysylamy caly backlog */
-				for (w = windows; w; w = w->next) {
+				for (wlist = windows; wlist; wlist = wlist->next) {
+					window_t *w = wlist->data;
 					remote_window_t *n = w->priv_data;
 					int i;
 
@@ -565,9 +568,10 @@ static WATCHER_LINE(rc_input_handler_line) {
 			remote_writefd(fd, "+SESSION", NULL);
 
 		} else if (!xstrcmp(cmd, "REQWINDOWS")) {
-			window_t *w;
+			GSList *wlist;
 
-			for (w = windows; w; w = w->next) {
+			for (wlist = windows; wlist; wlist = wlist->next) {
+				window_t *w = wlist->data;
 				remote_window_t *n;
 
 				remote_writefd(fd, "WINDOW", itoa(w->id), w->target, NULL);	/* NOTE: w->target can be NULL */
@@ -595,7 +599,7 @@ static WATCHER_LINE(rc_input_handler_line) {
 
 #define fix(x) ((x) ? x : "")
 			session_t *s;
-			window_t *w;
+			GSList *wlist;
 			userlist_t *u;
 
 			/* najpierw sesyjna userlista */
@@ -608,7 +612,8 @@ static WATCHER_LINE(rc_input_handler_line) {
 			}
 
 			/* potem okienkowe userlisty */
-			for (w = windows; w; w = w->next) {
+			for (wlist = windows; wlist; wlist = wlist->next) {
+				window_t *w = wlist->data;
 				for (u = w->userlist; u; u = u->next) {
 					char *groups = (u->groups) ? group_to_string(u->groups, 1, 0) : NULL;
 					remote_writefd(fd, "WINDOWITEM", itoa(w->id), fix(u->uid), itoa(u->status), fix(u->nickname), fix(groups), fix(u->descr), NULL);
@@ -1608,7 +1613,7 @@ EXPORT int remote_plugin_init(int prio) {
 }
 
 static int remote_plugin_destroy() {
-	window_t *w;
+	GSList *wlist;
 	list_t l;
 
 	for (l = rc_inputs; l;) {
@@ -1619,8 +1624,10 @@ static int remote_plugin_destroy() {
 		rc_input_close(r);
 	}
 
-	for (w = windows; w; w = w->next)
+	for (wlist = windows; wlist; wlist = wlist->next) {
+		window_t *w = wlist->data;
 		remote_window_kill(w);
+	}
 
 	plugin_unregister(&remote_plugin);
 	return 0;
