diff -Naur ORIG/alternate-tab@gnome-shell-extensions.gnome.org/extension.js MODIFIED/alternate-tab@gnome-shell-extensions.gnome.org/extension.js
--- ORIG/alternate-tab@gnome-shell-extensions.gnome.org/extension.js	2011-10-29 21:51:31.017819515 +0100
+++ MODIFIED/alternate-tab@gnome-shell-extensions.gnome.org/extension.js	2011-11-20 09:57:35.638705206 +0000
@@ -45,6 +45,7 @@
 
     show : function(backward) {
         let windows = global.get_window_actors();
+        let activeWorkspace = global.screen.get_active_workspace();
 
 	let list = '';
 	let normal_windows= [];
@@ -52,20 +53,38 @@
 	let tracker = Shell.WindowTracker.get_default();
 	let apps = tracker.get_running_apps ('');
 
-	for (let w = windows.length-1; w >= 0; w--) {
+        let fullList = 0;
+        for (let pass = 0; pass < 2; pass++) {
+          let found = 0;
+
+	  for (let w = windows.length-1; w >= 0; w--) {
 	    let win = windows[w].get_meta_window();
-	    if (win.window_type == 0) {
+
+            let inCurWS = win.get_workspace() == activeWorkspace;
+            if(inCurWS || (pass == 1)) {
+
+	      if (win.window_type == 0) {
 	        normal_windows.push(win);
-	    }
-	}
+                found = 1;
+                if(pass == 1)
+                  fullList = 1;
+	      }
+            }
+
+	  }
+          if(found)
+            break;
+        }
 	normal_windows.sort(Lang.bind(this, this._sortWindows));
 
-        let win_on_top = normal_windows.shift();
-        normal_windows.push(win_on_top);
+        if(normal_windows.length && !fullList) { // Fix for the first problem described in bug 663064
+          let win_on_top = normal_windows.shift();
+          normal_windows.push(win_on_top);
+        }
+
 	windows = normal_windows;
 	for (let w = 0; w < windows.length; w++) {
 	    let win = windows[w];
-
 	    let ap1 = null;
 	    for (let i = 0;i < apps.length; i++) {
 	        let app_wins = apps[i].get_windows();
@@ -78,8 +97,10 @@
 	    appIcons.push(ap1); 
 	}
 
-        if (!windows.length)
+        if (!windows.length) {
+            this.destroy(); // Fix for bug 663064 - alternate-tab shell error on alt-tab if no windows open
             return false;
+        }
 
         if (!Main.pushModal(this.actor))
             return false;
@@ -186,7 +207,17 @@
         this._windows = windows;
         this._arrows= new Array();
         this.icons= new Array();
-	for (let w = 0; w < windows.length; w++) {
+
+        for (let pass = 0; pass < 2; pass++) {
+         let found = 0;
+	 for (let w = 0; w < windows.length; w++) {
+
+	  let win=windows[w];
+          let inCurWS = win.get_workspace() == activeWorkspace;
+          if(inCurWS || (pass == 1)) {
+
+            found = 1;
+
             let arrow = new St.DrawingArea({ style_class: 'switcher-arrow' });
             arrow.connect('repaint', Lang.bind(this, function (area) {
                 Shell.draw_box_pointer(area, Shell.PointerDirection.DOWN);
@@ -196,8 +227,6 @@
 
             arrow.hide();
 
-	    let win=windows[w];
-
 	    let tracker = Shell.WindowTracker.get_default();
 	    let apps = tracker.get_running_apps ('');
 	    let ap1 = null;
@@ -222,7 +251,11 @@
   	    }
 	    ap1.cachedWindows = [win];
             this._addIcon(ap1);
-	}
+          }
+	 }
+         if(found)
+           break;
+        }
     },
 
     addSeparator: function () {
