--- nfx.c.orig	2010-01-11 10:20:03.000000000 +0100
+++ nfx.c	2010-01-11 10:20:37.000000000 +0100
@@ -262,24 +262,36 @@
 			free(extension_map_list->slot[i]->map);
 			free(extension_map_list->slot[i]);
 			extension_map_list->slot[i] = NULL;
+			dbg_printf("Free slot: %i\n", i);
 		}
 		if ( extension_map_list->slot[i] == NULL && free_slot == -1 ) {
 			// remember this free slot
-			dbg_printf("Found free slot at %i\n", i);
+			dbg_printf("Remember free slot at %i\n", i);
 			free_slot = i;
 		} else if ( free_slot != -1 && extension_map_list->slot[i] != NULL ) {
+			int j;
 			// move this slot down to compact the list
 			extension_map_list->slot[free_slot] = extension_map_list->slot[i];
+			extension_map_list->slot[free_slot]->map->map_id = free_slot;
 			extension_map_list->slot[i] = NULL;
 			dbg_printf("Move slot %i down to %i\n", i, free_slot);
-			free_slot = i;
+
+			// search for next free slot - latest slot[i] is free now
+			for ( j = free_slot + 1; j <= i; j++ ) {
+				if ( extension_map_list->slot[j] == NULL ) {
+					free_slot = j;
+					dbg_printf("Next free slot found at %i\n", free_slot);
+					break;
+				}
+			}
+		} else {
+			dbg_printf("Fell through\n");
 		}
 	}
 
 	// get max index - set index to map
 	i = 0;
 	while ( extension_map_list->slot[i] != NULL && i < MAX_EXTENSION_MAPS ) {
-		extension_map_list->slot[i]->map->map_id = i;
 		dbg_printf("Slot: %i, ref: %u\n", i, extension_map_list->slot[i]->ref_count);
 		i++;
 	}
@@ -320,6 +332,16 @@
 	extension_map_list->max_used = free_slot - 1;
 	dbg_printf("Packed maps: %i\n", free_slot);
 
+#ifdef DEVEL
+	// Check maps
+	i = 0;
+	while ( extension_map_list->slot[i] != NULL && i < MAX_EXTENSION_MAPS ) {
+		if ( extension_map_list->slot[i]->map->map_id != i ) 
+			printf("*** Map ID missmatch in slot: %i, id: %u\n", i, extension_map_list->slot[i]->map->map_id);
+		i++;
+	}
+#endif
+
 } // End of PackExtensionMapList
 
 void SetupExtensionDescriptors(char *options) {
