diff --git a/mkapachepw.py b/mkapachepw.py
index f7ed375..20ba7da 100755
--- a/mkapachepw.py
+++ b/mkapachepw.py
@@ -9,7 +9,7 @@
 # Program Information
 
 PROGNAME = "mkapachepw"
-RCSID = "$Id: mkapachepw.py,v 1.106 2005/04/02 09:03:53 root Exp $"
+RCSID = "$Id: mkapachepw.py,v 1.107 2005/04/04 21:41:37 root Exp $"
 VERSION = RCSID.split()[2]
 
 # Copyright Information
@@ -113,13 +113,7 @@
 CFGFILE            = ""          # Default is no config file
 
 groups             = {}          # Place to store group information
-groups_excluded    = []          # List of GIDs *not* to include in output
-groups_included    = []          # List of GIDs to *always* include in output
-
 users              = {}          # Place to store user information
-users_excluded     = []          # List of UIDs *not* to include in output
-users_included     = []          # List of UIDs to *always* include in output
-
 
 
 #--------------------------- Code Begins Here ---------------------------------#
@@ -158,45 +152,66 @@
 
 
 #####
-# Process An Enumerated List Of Groups/Users To Include Or Exclude
+# Process An Enumerated List Of Groups/Users To Include Or Exclude.
+#
+# The 'items' argument must be a string with the names or numbers to
+# process, with a '-' or '+' prepended to indicate Delete or Add,
+# respectively.
 #####
 
-def ProcessEnumeratedList(items, master, excluded, included, name):
+def ProcessEnumeratedList(items, master, lookup, name):
 
     for item in items.split():
         orig = item
         
-        # Exclude Processing
+        # Verify argument is in correct format and determine type of
+        # operation desired.
 
         if item[0] == '-':
-            item = item[1:]
-            savein = excluded
-
-        # Include Processing
+            additem = False
 
         elif item[0] == '+':
-            item = item[1:]
-            savein = included
+            additem = True
 
-        # Bad Format
-        
         else:
             ErrorMsg("'%s' Must Be Prefixed With '+' or '-' To Indicate Desired Action." % item)
             sys.exit(2)
 
-        # See if it's a number
+        item = item[1:]     # We just need the item ID portion
+
+        # See if it's a GID/UID (a number)
         try:
             item = int(item)
-            if item not in master:
-                ErrorMsg("%s '%s' Does Not Exist!" % (name, orig[1:]))
-                sys.exit(2)
 
+            # Make sure it even exists
+
+            if item not in master:
+                ErrorMsg("'%s' Is An Invalid %s ID." % (item, name))
+                sys.exit(2)
+            
         # If not, assume it is a name and look it up
         except ValueError:
-            print item
 
-        if item not in savein:
-            savein.append(item)
+            # Handle the case where the name does not exist
+            try:
+                item = lookup(item)[2]
+
+            except:
+                ErrorMsg("'%s' Is An Invalid %s Name." % (orig[1:], name))
+                sys.exit(2)
+
+
+        print additem, item
+
+        # Do the actual in/exclusion
+
+        # Include
+        if additem:
+            master[item][2] = True   # Mark entry as protected
+
+        # Exclude
+        else:
+            del master[item]
 
 # End of 'ProcessEnumeratedList(()'
 
@@ -211,6 +226,8 @@
 # Command Line Parsing May Need This Information.
 #####
 
+Protected = False
+
 #####
 # Build List Of Groups
 #####
@@ -219,7 +236,7 @@
 
     gname, gpw, gid, gmembers = group[:4]
 
-    groups[gid] = (gname, [])
+    groups[gid] = [gname, [], Protected]
     for member in gmembers:
         groups[gid][1].append(member)
 
@@ -231,7 +248,7 @@
 
     uname, pw, uid, gid = user[:4]
 
-    users[uid] = (uname, pw)
+    users[uid] = [uname, pw, Protected]
     if uname not in groups[gid][1]:
         groups[gid][1].append(uname)
 
@@ -254,9 +271,9 @@
 
 for opt, val in opts:
     if opt == "-G":
-        ProcessEnumeratedList(val, groups, groups_excluded, groups_included, "Group")
+        ProcessEnumeratedList(val, groups, grp.getgrnam, "Group")
     if opt == "-U":
-        ProcessEnumeratedList(val, users, users_excluded, users_included, "User")
+        ProcessEnumeratedList(val, users, pwd.getpwnam, "User")
     if opt == "-f":
         CFGFILE=val
     if opt == "-g":
@@ -270,9 +287,7 @@
         print RCSID
         sys.exit(0)
 
-print groups_excluded, groups_included, users_excluded, users_included
-
-
+print users, groups
 
 #####
 # Write Out The Files
@@ -287,8 +302,10 @@
 grfile = open(GRFILE, "w")
 grfile.write(TIMESTAMP)
 
+# Write out groups if they are either protected or >= specified starting ID
+
 for gid in groups:
-    if gid >= STARTGID:
+    if (groups[gid][2]) or (gid >= STARTGID):
         grfile.write("%s: %s\n" % (groups[gid][0], " ".join(groups[gid][1])))
 
 grfile.close()
@@ -298,8 +315,11 @@
 pwfile = open(PWFILE, "w")
 pwfile.write(TIMESTAMP)
 
+# Write out users if they are either protected or >= specified starting ID
+
 for uid in users:
-    if uid >= STARTUID:
-        pwfile.write("%s:%s\n" % users[uid][:])
+    print users[uid]
+    if (users[uid][2]) or (uid >= STARTUID):
+        pwfile.write("%s:%s\n" % tuple(users[uid])[:2])
 
 pwfile.close()