diff --git a/src/hostinfo/dhcpd.py b/src/hostinfo/dhcpd.py
index 9654a47ffdd76619924f13af852d1a854bcac805..918a3a8c8305299f8edaabcb373c784838b44c2d 100755
--- a/src/hostinfo/dhcpd.py
+++ b/src/hostinfo/dhcpd.py
@@ -80,8 +80,9 @@ option PXE.mtftp-tmout code 4 = unsigned integer 8;
 option PXE.mtftp-delay code 5 = unsigned integer 8;
 option arch code 93 = unsigned integer 16; # RFC4578
 
-class "pxeclient_allow" {
+class "pxeclient" {
   match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
+  next-server %(next_server)s;
   if option arch = 00:06 {
     filename "bootia32.efi";
   } else if option arch = 00:07 {
@@ -93,31 +94,12 @@ class "pxeclient_allow" {
 """
 
 PXE_DENY="""
-class "pxeclient_deny" {
-  match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
-  ignore booting;
-}
-"""
-
-CLASS_PXECLIENT = """
 class "pxeclient" {
   match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
-    next-server %(next_server)s;
-    if option arch = 00:06 {
-      filename "bootia32.efi";
-    } else if option arch = 00:07 {
-      filename "bootx64.efi";
-    } else {
-      filename "pxelinux.0";
-    }
-  }
-}
-
-class "noboot" {
-  match if substring (option vendor-class-identifier, 0, 9) != "PXEClient";
   ignore booting;
 }
 """
+
 def MacOS_NETBOOT(dhcphost):
     if not os.path.exists('/local/macos'):
         return ''
@@ -175,7 +157,10 @@ def generate(tree, options):
       |use-host-decl-names on;
     """)
     if get_pxeboot(dhcp) == 'only':
-        result += PXE_ALLOW
+        if not options.next_server:
+            raise util.HostinfoException('next_server not defined',
+                                   where=dhcp)
+        result += PXE_ALLOW % dict(next_server=options.next_server)
         pass
     else:
         result += PXE_DENY
@@ -193,7 +178,8 @@ def generate(tree, options):
 
 def emit_interface(tree, options, interface):
     result = util.StringArray()
-    subnet = dict(map(lambda d: (get_subnet(tree, d._parent), d),
+    subnet = dict(map(lambda d: (get_subnet(tree, d._parent), 
+                                 map(None, d._parent._dhcpserver_)),
                       interface._ip_._dhcpserver_))
     result += 'shared-network "MAC(%s)" {' % interface.ethernet[0]
     for sn,dhcp in map(lambda n: (n, subnet[n]), sorted(subnet)): 
@@ -217,20 +203,22 @@ def emit_network(tree, options, subnet, dhcp):
                  netmask=net.netmask,
                  broadcast=net.broadcast,
                  host=options.host))
-    if dhcp.first[0] and dhcp.last[0]:
-        first = util.address(dhcp.first[0])
-        last = util.address(dhcp.last[0])
-        assert first in net, '%s not part of %s' % (first, net)
-        assert last in net, '%s not part of %s' % (last, net)
-        if pxeboot == 'no':
-            result += "  range %s %s;" % (first, last)
-            pass
-        elif pxeboot == 'only':
-            result.append_lines("""
-              |  pool {
-              |    allow members of "pxeclient";
-              |    range %(first)s %(last)s;
-              |  }""" % dict(first=first, last=last))
+    for d in dhcp:
+        if d.first[0] and d.last[0]:
+            first = util.address(d.first[0])
+            last = util.address(d.last[0])
+            assert first in net, '%s not part of %s' % (first, net)
+            assert last in net, '%s not part of %s' % (last, net)
+            if pxeboot == 'no':
+                result += "  range %s %s;" % (first, last)
+                pass
+            elif pxeboot == 'only':
+                result.append_lines("""
+                  |  pool {
+                  |    allow members of "pxeclient";
+                  |    range %(first)s %(last)s;
+                  |  }""" % dict(first=first, last=last))
+                pass
             pass
         pass
     result += emit_subnet_info(subnet).indent()
@@ -346,7 +334,10 @@ def get_subnet(tree, ip):
 def get_pxeboot(dhcp):
     try:
         p = set(map(lambda d: d.pxeboot[0] or 'no', dhcp))
-        assert len(p) == 1, "Mixed pxeboot not allowed (%s)" % ','.join(p)
+        if len(p) != 1:
+            raise util.HostinfoException("Mixed pxeboot not allowed (%s)" % 
+                                         ','.join(p),
+                                         where=dhcp)
         result = p.pop()
         pass
     except TypeError:
diff --git a/src/hostinfo/yp.py b/src/hostinfo/yp.py
index b5284a2cc176621dd7047d384922b891e7163bea..ff26a2f627bb2f04527ad90857c377215c1a4fb5 100755
--- a/src/hostinfo/yp.py
+++ b/src/hostinfo/yp.py
@@ -103,9 +103,16 @@ def netgroup(tree):
             pass
         pass
     for g in tree._host_._interface_._netgroup_:
-        for ip in filter(lambda ip: (not ip.alias[0] and not ip.vlan[0] and 
-                                     not ip.never[0]),
-                         g._parent._ip_):
+        def exclude(ip):
+           if ip.alias[0] or ip.vlan[0] or ip.never[0]:
+               return False
+           if ip.exclude_netgroups[0]:
+               if g.name[0] in ip.exclude_netgroups[0].split(','):
+                   return False
+               pass
+           return True
+
+        for ip in filter(exclude, g._parent._ip_):
             if not g.name[0:] in netgroup:
                 netgroup[g.name[0:]] = [ ]
                 pass