Index: src/java/org/jivesoftware/spark/ui/ContactList.java
===================================================================
--- src/java/org/jivesoftware/spark/ui/ContactList.java	(revision 10989)
+++ src/java/org/jivesoftware/spark/ui/ContactList.java	(working copy)
@@ -447,16 +447,14 @@
 
         if (!isFiled) {
             ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
-            if (unfiledGroup == null) {
-                unfiledGroup = new ContactGroup(Res.getString("unfiled"));
-                addContactGroup(unfiledGroup);
-            }
-            unfiledGroup.addContactItem(contactItem);
+            
+            ContactGroup unfiledGrp = getUnfiledGroup();
+            unfiledGrp.addContactItem(contactItem);
             contactItem.setPresence(presence);
             contactItem.setAvailable(true);
 
-            unfiledGroup.setVisible(true);
-            unfiledGroup.fireContactGroupUpdated();
+            unfiledGrp.setVisible(true);
+            unfiledGrp.fireContactGroupUpdated();
         }
     }
 
@@ -477,22 +475,35 @@
         }
 
         for (RosterGroup group : roster.getGroups()) {
-            ContactGroup contactGroup = getContactGroup(group.getName());
+        	
+        	if(group.getName() == null || group.getName() == ""){
+        		for(RosterEntry entry : group.getEntries()){
+        			
+        			ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
+                    moveToOffline(contactItem);
+        		}
+        	}else{
+        		
+	            ContactGroup contactGroup = getContactGroup(group.getName());
+	            if (contactGroup == null) {
+	                contactGroup = getUnfiledGroup();
+	            }
 
-            for (RosterEntry entry : group.getEntries()) {
-                ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
-                contactItem.setPresence(new Presence(Presence.Type.unavailable));
-                if ((entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
-                    && RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
-                    // Add to contact group.
-                    contactGroup.addContactItem(contactItem);
-                    contactGroup.setVisible(true);
-                }
-                else {
-                    if (offlineGroup.getContactItemByJID(entry.getUser()) == null) {
-                        moveToOffline(contactItem);
-                    }
-                }
+	            for (RosterEntry entry : group.getEntries()) {
+	                ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
+	                contactItem.setPresence(new Presence(Presence.Type.unavailable));
+	                if ((entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
+	                    && RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
+	                    // Add to contact group.
+	                    contactGroup.addContactItem(contactItem);
+	                    contactGroup.setVisible(true);
+	                }
+	                else {
+	                    if (offlineGroup.getContactItemByJID(entry.getUser()) == null) {
+	                        moveToOffline(contactItem);
+	                    }
+	                }
+            	}
             }
         }
 
@@ -498,10 +509,6 @@
 
         // Add Unfiled Group
         for (RosterEntry entry : roster.getUnfiledEntries()) {
-            if (unfiledGroup == null) {
-                unfiledGroup = new ContactGroup(Res.getString("unfiled"));
-                addContactGroup(unfiledGroup);
-            }
             ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
             moveToOffline(contactItem);
         }
@@ -685,7 +692,7 @@
 
                             for (ContactGroup group : new ArrayList<ContactGroup>(getContactGroups())) {
                                 ContactItem itemFound = group.getContactItemByJID(jid);
-                                if (itemFound != null && !unfiled && group != unfiledGroup && group != offlineGroup) {
+                                if (itemFound != null && !unfiled && group != getUnfiledGroup() && group != offlineGroup) {
                                     if (!userGroupSet.contains(group.getGroupName())) {
                                         removeContactGroup(group);
                                     }
@@ -698,8 +705,9 @@
                         if (!isUnfiled) {
                             return;
                         }
-
-                        ContactItem unfiledItem = unfiledGroup.getContactItemByJID(jid);
+                        
+                        ContactGroup unfiledGrp = getUnfiledGroup();
+                        ContactItem unfiledItem = unfiledGrp.getContactItemByJID(jid);
                         if (unfiledItem != null) {
 
                         }
@@ -710,9 +718,9 @@
                                     && RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == rosterEntry.getStatus()) {
                                     // Remove from offlineItem and add to unfiledItem.
                                     offlineGroup.removeContactItem(offlineItem);
-                                    unfiledGroup.addContactItem(offlineItem);
-                                    unfiledGroup.fireContactGroupUpdated();
-                                    unfiledGroup.setVisible(true);
+                                    unfiledGrp.addContactItem(offlineItem);
+                                    unfiledGrp.fireContactGroupUpdated();
+                                    unfiledGrp.setVisible(true);
                                 }
                             }
                         }
@@ -878,7 +886,7 @@
                 newContactGroup.setGroupName(realGroupName);
             }
             else {
-                if (newContactGroup != offlineGroup && newContactGroup != unfiledGroup) {
+                if (newContactGroup != offlineGroup && newContactGroup != getUnfiledGroup()) {
                     rootGroup = newContactGroup;
                     continue;
                 }
@@ -1216,7 +1224,7 @@
 
     public void contactGroupPopup(MouseEvent e, final ContactGroup group) {
    	  // Do nothing with offline group
-        if (group == offlineGroup || group == unfiledGroup) {
+        if (group == offlineGroup || group == getUnfiledGroup()) {
             return;
         }
 
@@ -1354,7 +1362,7 @@
         ContactGroup contactGroup = getContactGroup(groupName);
 
         // Only show "Remove Contact From Group" if the user belongs to more than one group.
-        if (!contactGroup.isSharedGroup() && !contactGroup.isOfflineGroup() && contactGroup != unfiledGroup) {
+        if (!contactGroup.isSharedGroup() && !contactGroup.isOfflineGroup() && contactGroup != getUnfiledGroup()) {
             Roster roster = SparkManager.getConnection().getRoster();
             RosterEntry entry = roster.getEntry(item.getJID());
             if (entry != null) {
@@ -1922,7 +1930,7 @@
     }
 
     private void checkGroup(ContactGroup group) {
-        if (!group.hasAvailableContacts() && group != offlineGroup && group != unfiledGroup && !showHideMenu.isSelected()) {
+        if (!group.hasAvailableContacts() && group != offlineGroup && group != getUnfiledGroup() && !showHideMenu.isSelected()) {
             group.setVisible(false);
         }
     }
@@ -2151,6 +2159,9 @@
         final Roster roster = SparkManager.getConnection().getRoster();
         for (RosterGroup group : roster.getEntry(jid).getGroups()) {
             ContactGroup contactGroup = getContactGroup(group.getName());
+            if(contactGroup == null && group.getName() != ""){
+            	contactGroup = addContactGroup(group.getName());
+            }
             if (contactGroup != null) {
                 isFiled = true;
                 contactGroup.addOfflineContactItem(contactItem.getAlias(), contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
@@ -2157,7 +2168,7 @@
             }
         }
         if (!isFiled) {
-            unfiledGroup.addOfflineContactItem(contactItem.getAlias(), contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
+            getUnfiledGroup().addOfflineContactItem(contactItem.getAlias(), contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
         }
         
         if(localPreferences.isOfflineUsersShown() == false)
@@ -2172,6 +2183,15 @@
         }
     }
 
+    private ContactGroup getUnfiledGroup() {
+        if (unfiledGroup == null) {
+            // Add Unfiled Group
+            unfiledGroup = new ContactGroup(Res.getString("unfiled"));
+            addContactGroup(unfiledGroup);
+        }
+        return unfiledGroup;
+    }
+
     /**
      * Sorts ContactItems.
      */
@@ -2181,12 +2201,4 @@
         }
     };
 
-}
-
-
-
-
-
-
-
-
+}
\ No newline at end of file
