diff --git a/src/workspaces.c b/src/workspaces.c
index 45c0cb94ca41a9546c0251cbaf61adf2b449a7b0..1180eac457752c688727d8df258351caed39b35a 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -74,17 +74,8 @@ void workspaceSwitch(int new_ws, Client * c2)
 
     workspace = new_ws;
 
-    /* 
-       Do the switch in two passes :
-       - The first one, unmapping windows from bottom to top 
-       - The second pass, mapping from top to bottom
-
-       ==> this save a lot of expose events and make things a lot faster ;-)
-     */
-
     /* First pass */
-    for(last = clients, i = 0; i < client_count; last = last->next, i++);
-    for(c = last, i = 0; i < client_count; c = c->prev, i++)
+    for(c = clients->prev, i = 0; (c) && (i < client_count); c = c->prev, i++)
     {
         if(CLIENT_FLAG_TEST_AND_NOT(c, CLIENT_FLAG_VISIBLE, CLIENT_FLAG_STICKY) && !(c->transient_for) && ((c->win_workspace != new_ws)))
         {
@@ -92,7 +83,7 @@ void workspaceSwitch(int new_ws, Client * c2)
         }
     }
     /* Second pass */
-    for(c = clients, i = 0; i < client_count; c = c->next, i++)
+    for(c = clients, i = 0; (c) && (i < client_count); c = c->next, i++)
     {
         if(CLIENT_FLAG_TEST(c, CLIENT_FLAG_STICKY))
         {
@@ -145,7 +136,7 @@ void workspaceSetCount(int count)
     setNetHint(dpy, root, net_number_of_desktops, count);
     params.workspace_count = count;
 
-    for(c = clients, i = 0; i < client_count; c = c->next, i++)
+    for(c = clients, i = 0; (c) && (i < client_count); c = c->next, i++)
     {
         if(c->win_workspace > count - 1)
         {
@@ -174,7 +165,7 @@ void workspaceUpdateArea(CARD32 * margins, CARD32 * gnome_margins)
     {
         margins[i] = gnome_margins[i];
     }
-    for(c = clients, i = 0; i < client_count; c = c->next, i++)
+    for(c = clients, i = 0; (c) && (i < client_count); c = c->next, i++)
     {
         if(CLIENT_FLAG_TEST_ALL(c, CLIENT_FLAG_HAS_STRUTS | CLIENT_FLAG_VISIBLE))
         {