Index: trunk/psLib/src/astronomy/psMetadata.c
===================================================================
--- trunk/psLib/src/astronomy/psMetadata.c	(revision 1458)
+++ trunk/psLib/src/astronomy/psMetadata.c	(revision 1493)
@@ -12,6 +12,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-10 23:32:51 $
+*  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-12 00:40:42 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -413,8 +413,8 @@
 
             // Table entry has children. Entry and children must be removed from metadata collection's list
-            psListSetIterator(mdList, PS_LIST_HEAD);
-            entryChild = psListGetCurrent(mdList);
+            psListSetIterator(entry->items, PS_LIST_HEAD);
+            entryChild = psListGetCurrent(entry->items);
             while (entryChild != NULL) {
-                if (!psListRemove(entry->items, entryChild, PS_LIST_UNKNOWN)) {
+                if (!psListRemove(mdList, entryChild, PS_LIST_UNKNOWN)) {
                     psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
                     return false;
@@ -422,9 +422,11 @@
                 entryChild = psListGetNext(entry->items);
             }
-        }
-        // Remove entry from metadata collection's list
-        if (!psListRemove(mdList, entry, PS_LIST_UNKNOWN)) {
-            psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
-            return false;
+        } else {
+
+            // Table entry has no children. Remove entry from metadata collection's list
+            if (!psListRemove(mdList, entry, PS_LIST_UNKNOWN)) {
+                psError(__func__, "Couldn't remove metadata item from list. Name: %s", key);
+                return false;
+            }
         }
         // Remove entry from metadata collection's table
