diff --git a/lib/distribute.c b/lib/distribute.c
index ba8043c..4603e13 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -45,22 +45,33 @@
 static void
 distribute_free (struct distribute *dist)
 {
+  int i = 0;
   if (dist->ifname)
     XFREE (MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
 
-  if (dist->list[DISTRIBUTE_IN])
-    free (dist->list[DISTRIBUTE_IN]);
-  if (dist->list[DISTRIBUTE_OUT])
-    free (dist->list[DISTRIBUTE_OUT]);
+  for (i=0; i < DISTRIBUTE_MAX; i++)
+    if (dist->list[i])
+      free(dist->list[i]);
 
-  if (dist->prefix[DISTRIBUTE_IN])
-    free (dist->prefix[DISTRIBUTE_IN]);
-  if (dist->prefix[DISTRIBUTE_OUT])
-    free (dist->prefix[DISTRIBUTE_OUT]);
+  for (i=0; i < DISTRIBUTE_MAX; i++)
+    if (dist->prefix[i])
+      free(dist->prefix[i]);
 
   XFREE (MTYPE_DISTRIBUTE, dist);
 }
 
+static void
+distribute_free_if_empty(struct distribute *dist)
+{
+  int i;
+  for (i=0; i < DISTRIBUTE_MAX; i++)
+    if (dist->list[i] != NULL || dist->prefix[i] != NULL)
+      return;
+
+  hash_release (disthash, dist);
+  distribute_free (dist);
+}
+
 /* Lookup interface's distribute list. */
 struct distribute *
 distribute_lookup (const char *ifname)
@@ -136,36 +147,27 @@
 
 /* Set access-list name to the distribute list. */
 static struct distribute *
-distribute_list_set (const char *ifname, enum distribute_type type, 
+distribute_list_set (const char *ifname, enum distribute_type type,
                      const char *alist_name)
 {
   struct distribute *dist;
 
   dist = distribute_get (ifname);
 
-  if (type == DISTRIBUTE_IN)
-    {
-      if (dist->list[DISTRIBUTE_IN])
-	free (dist->list[DISTRIBUTE_IN]);
-      dist->list[DISTRIBUTE_IN] = strdup (alist_name);
-    }
-  if (type == DISTRIBUTE_OUT)
-    {
-      if (dist->list[DISTRIBUTE_OUT])
-	free (dist->list[DISTRIBUTE_OUT]);
-      dist->list[DISTRIBUTE_OUT] = strdup (alist_name);
-    }
+  if (dist->list[type])
+    free (dist->list[type]);
+  dist->list[type] = strdup (alist_name);
 
   /* Apply this distribute-list to the interface. */
   (*distribute_add_hook) (dist);
-  
+
   return dist;
 }
 
 /* Unset distribute-list.  If matched distribute-list exist then
    return 1. */
 static int
-distribute_list_unset (const char *ifname, enum distribute_type type, 
+distribute_list_unset (const char *ifname, enum distribute_type type,
 		       const char *alist_name)
 {
   struct distribute *dist;
@@ -174,41 +176,19 @@
   if (!dist)
     return 0;
 
-  if (type == DISTRIBUTE_IN)
-    {
-      if (!dist->list[DISTRIBUTE_IN])
-	return 0;
-      if (strcmp (dist->list[DISTRIBUTE_IN], alist_name) != 0)
-	return 0;
+  if (!dist->list[type])
+    return 0;
+  if (strcmp (dist->list[type], alist_name) != 0)
+    return 0;
 
-      free (dist->list[DISTRIBUTE_IN]);
-      dist->list[DISTRIBUTE_IN] = NULL;      
-    }
-
-  if (type == DISTRIBUTE_OUT)
-    {
-      if (!dist->list[DISTRIBUTE_OUT])
-	return 0;
-      if (strcmp (dist->list[DISTRIBUTE_OUT], alist_name) != 0)
-	return 0;
-
-      free (dist->list[DISTRIBUTE_OUT]);
-      dist->list[DISTRIBUTE_OUT] = NULL;      
-    }
+  free (dist->list[type]);
+  dist->list[type] = NULL;
 
   /* Apply this distribute-list to the interface. */
   (*distribute_delete_hook) (dist);
 
-  /* If both out and in is NULL then free distribute list. */
-  if (dist->list[DISTRIBUTE_IN] == NULL &&
-      dist->list[DISTRIBUTE_OUT] == NULL &&
-      dist->prefix[DISTRIBUTE_IN] == NULL &&
-      dist->prefix[DISTRIBUTE_OUT] == NULL)
-    {
-      hash_release (disthash, dist);
-      distribute_free (dist);
-    }
-
+  /* If all dist are NULL, then free distribute list. */
+  distribute_free_if_empty(dist);
   return 1;
 }
 
@@ -221,18 +201,9 @@
 
   dist = distribute_get (ifname);
 
-  if (type == DISTRIBUTE_IN)
-    {
-      if (dist->prefix[DISTRIBUTE_IN])
-	free (dist->prefix[DISTRIBUTE_IN]);
-      dist->prefix[DISTRIBUTE_IN] = strdup (plist_name);
-    }
-  if (type == DISTRIBUTE_OUT)
-    {
-      if (dist->prefix[DISTRIBUTE_OUT])
-	free (dist->prefix[DISTRIBUTE_OUT]);
-      dist->prefix[DISTRIBUTE_OUT] = strdup (plist_name);
-    }
+  if (dist->prefix[type])
+    free (dist->prefix[type]);
+  dist->prefix[type] = strdup (plist_name);
 
   /* Apply this distribute-list to the interface. */
   (*distribute_add_hook) (dist);
@@ -252,41 +223,19 @@
   if (!dist)
     return 0;
 
-  if (type == DISTRIBUTE_IN)
-    {
-      if (!dist->prefix[DISTRIBUTE_IN])
-	return 0;
-      if (strcmp (dist->prefix[DISTRIBUTE_IN], plist_name) != 0)
-	return 0;
+  if (!dist->prefix[type])
+    return 0;
+  if (strcmp (dist->prefix[type], plist_name) != 0)
+    return 0;
 
-      free (dist->prefix[DISTRIBUTE_IN]);
-      dist->prefix[DISTRIBUTE_IN] = NULL;      
-    }
-
-  if (type == DISTRIBUTE_OUT)
-    {
-      if (!dist->prefix[DISTRIBUTE_OUT])
-	return 0;
-      if (strcmp (dist->prefix[DISTRIBUTE_OUT], plist_name) != 0)
-	return 0;
-
-      free (dist->prefix[DISTRIBUTE_OUT]);
-      dist->prefix[DISTRIBUTE_OUT] = NULL;      
-    }
+  free (dist->prefix[type]);
+  dist->prefix[type] = NULL;
 
   /* Apply this distribute-list to the interface. */
   (*distribute_delete_hook) (dist);
 
-  /* If both out and in is NULL then free distribute list. */
-  if (dist->list[DISTRIBUTE_IN] == NULL &&
-      dist->list[DISTRIBUTE_OUT] == NULL &&
-      dist->prefix[DISTRIBUTE_IN] == NULL &&
-      dist->prefix[DISTRIBUTE_OUT] == NULL)
-    {
-      hash_release (disthash, dist);
-      distribute_free (dist);
-    }
-
+  /* If all dist are NULL, then free distribute list. */
+  distribute_free_if_empty(dist);
   return 1;
 }
 
@@ -394,7 +343,7 @@
   distribute_list_set (argv[2], type, argv[0]);
 
   return CMD_SUCCESS;
-}       
+}
 
 ALIAS (distribute_list,
        ipv6_distribute_list_cmd,
@@ -435,7 +384,7 @@
       return CMD_WARNING;
     }
   return CMD_SUCCESS;
-}       
+}
 
 ALIAS (no_distribute_list, no_ipv6_distribute_list_cmd,
        "no distribute-list WORD (in|out) WORD",
@@ -473,7 +422,7 @@
   distribute_list_prefix_set (NULL, type, argv[0]);
 
   return CMD_SUCCESS;
-}       
+}
 
 ALIAS (distribute_list_prefix_all,
        ipv6_distribute_list_prefix_all_cmd,
@@ -516,7 +465,7 @@
       return CMD_WARNING;
     }
   return CMD_SUCCESS;
-}       
+}
 
 ALIAS (no_distribute_list_prefix_all,
        no_ipv6_distribute_list_prefix_all_cmd,
@@ -555,7 +504,7 @@
   distribute_list_prefix_set (argv[2], type, argv[0]);
 
   return CMD_SUCCESS;
-}       
+}
 
 ALIAS (distribute_list_prefix, ipv6_distribute_list_prefix_cmd,
        "distribute-list prefix WORD (in|out) WORD",
@@ -598,7 +547,7 @@
       return CMD_WARNING;
     }
   return CMD_SUCCESS;
-}       
+}
 
 ALIAS (no_distribute_list_prefix, no_ipv6_distribute_list_prefix_cmd,
        "no distribute-list prefix WORD (in|out) WORD",
@@ -610,80 +559,96 @@
        "Filter outgoing routing updates\n"
        "Interface name\n")
 
+static int
+distribute_print (struct vty *vty, char *tab[], int is_prefix,
+                  enum distribute_type type, int has_print)
+{
+  if (tab[type]) {
+    vty_out (vty, "%s %s%s",
+             has_print ? "," : "",
+             is_prefix ? "(prefix-list) " : "",
+             tab[type]);
+    return 1;
+  }
+  return has_print;
+}
+
 int
 config_show_distribute (struct vty *vty)
 {
   unsigned int i;
+  int has_print = 0;
   struct hash_backet *mp;
   struct distribute *dist;
 
   /* Output filter configuration. */
   dist = distribute_lookup (NULL);
-  if (dist && (dist->list[DISTRIBUTE_OUT] || dist->prefix[DISTRIBUTE_OUT]))
+  vty_out(vty, "  Outgoing update filter list for all interface is");
+  has_print = 0;
+  if (dist)
     {
-      vty_out (vty, "  Outgoing update filter list for all interface is");
-      if (dist->list[DISTRIBUTE_OUT])
-	vty_out (vty, " %s", dist->list[DISTRIBUTE_OUT]);
-      if (dist->prefix[DISTRIBUTE_OUT])
-	vty_out (vty, "%s (prefix-list) %s",
-		 dist->list[DISTRIBUTE_OUT] ? "," : "",
-		 dist->prefix[DISTRIBUTE_OUT]);
-      vty_out (vty, "%s", VTY_NEWLINE);
+      has_print = distribute_print(vty, dist->list,   0,
+                                   DISTRIBUTE_OUT, has_print);
+      has_print = distribute_print(vty, dist->prefix, 1,
+                                   DISTRIBUTE_OUT, has_print);
     }
+  if (has_print)
+    vty_out (vty, "%s", VTY_NEWLINE);
   else
-    vty_out (vty, "  Outgoing update filter list for all interface is not set%s", VTY_NEWLINE);
+    vty_out (vty, " not set%s", VTY_NEWLINE);
 
   for (i = 0; i < disthash->size; i++)
     for (mp = disthash->index[i]; mp; mp = mp->next)
       {
 	dist = mp->data;
 	if (dist->ifname)
-	  if (dist->list[DISTRIBUTE_OUT] || dist->prefix[DISTRIBUTE_OUT])
-	    {
-	      vty_out (vty, "    %s filtered by", dist->ifname);
-	      if (dist->list[DISTRIBUTE_OUT])
-		vty_out (vty, " %s", dist->list[DISTRIBUTE_OUT]);
-	      if (dist->prefix[DISTRIBUTE_OUT])
-		vty_out (vty, "%s (prefix-list) %s",
-			 dist->list[DISTRIBUTE_OUT] ? "," : "",
-			 dist->prefix[DISTRIBUTE_OUT]);
-	      vty_out (vty, "%s", VTY_NEWLINE);
-	    }
+          {
+            vty_out (vty, "    %s filtered by", dist->ifname);
+            has_print = 0;
+            has_print = distribute_print(vty, dist->list,   0,
+                                         DISTRIBUTE_OUT, has_print);
+            has_print = distribute_print(vty, dist->prefix, 1,
+                                         DISTRIBUTE_OUT, has_print);
+            if (has_print)
+              vty_out (vty, "%s", VTY_NEWLINE);
+            else
+              vty_out(vty, " nothing%s", VTY_NEWLINE);
+          }
       }
 
 
   /* Input filter configuration. */
   dist = distribute_lookup (NULL);
-  if (dist && (dist->list[DISTRIBUTE_IN] || dist->prefix[DISTRIBUTE_IN]))
+  vty_out(vty, "  Incoming update filter list for all interface is");
+  has_print = 0;
+  if (dist)
     {
-      vty_out (vty, "  Incoming update filter list for all interface is");
-      if (dist->list[DISTRIBUTE_IN])
-	vty_out (vty, " %s", dist->list[DISTRIBUTE_IN]);
-      if (dist->prefix[DISTRIBUTE_IN])
-	vty_out (vty, "%s (prefix-list) %s",
-		 dist->list[DISTRIBUTE_IN] ? "," : "",
-		 dist->prefix[DISTRIBUTE_IN]);
-      vty_out (vty, "%s", VTY_NEWLINE);
-    }
+      has_print = distribute_print(vty, dist->list,   0,
+                                   DISTRIBUTE_IN, has_print);
+      has_print = distribute_print(vty, dist->prefix, 1,
+                                   DISTRIBUTE_IN, has_print);    }
+  if (has_print)
+    vty_out (vty, "%s", VTY_NEWLINE);
   else
-    vty_out (vty, "  Incoming update filter list for all interface is not set%s", VTY_NEWLINE);
+    vty_out (vty, " not set%s", VTY_NEWLINE);
 
   for (i = 0; i < disthash->size; i++)
     for (mp = disthash->index[i]; mp; mp = mp->next)
       {
 	dist = mp->data;
-	if (dist->ifname)
-	  if (dist->list[DISTRIBUTE_IN] || dist->prefix[DISTRIBUTE_IN])
-	    {
-	      vty_out (vty, "    %s filtered by", dist->ifname);
-	      if (dist->list[DISTRIBUTE_IN])
-		vty_out (vty, " %s", dist->list[DISTRIBUTE_IN]);
-	      if (dist->prefix[DISTRIBUTE_IN])
-		vty_out (vty, "%s (prefix-list) %s",
-			 dist->list[DISTRIBUTE_IN] ? "," : "",
-			 dist->prefix[DISTRIBUTE_IN]);
-	      vty_out (vty, "%s", VTY_NEWLINE);
-	    }
+        if (dist->ifname)
+          {
+            vty_out (vty, "    %s filtered by", dist->ifname);
+            has_print = 0;
+            has_print = distribute_print(vty, dist->list,   0,
+                                         DISTRIBUTE_IN, has_print);
+            has_print = distribute_print(vty, dist->prefix, 1,
+                                         DISTRIBUTE_IN, has_print);
+            if (has_print)
+              vty_out (vty, "%s", VTY_NEWLINE);
+            else
+              vty_out(vty, " nothing%s", VTY_NEWLINE);
+          }
       }
   return 0;
 }
@@ -693,6 +658,8 @@
 config_write_distribute (struct vty *vty)
 {
   unsigned int i;
+  int j;
+  int output;
   struct hash_backet *mp;
   int write = 0;
 
@@ -703,38 +670,23 @@
 
 	dist = mp->data;
 
-	if (dist->list[DISTRIBUTE_IN])
-	  {
-	    vty_out (vty, " distribute-list %s in %s%s", 
-		     dist->list[DISTRIBUTE_IN],
+	for (j=0; j < DISTRIBUTE_MAX; j++)
+	  if (dist->list[j]) {
+	    output = j == DISTRIBUTE_OUT;
+	    vty_out (vty, " distribute-list %s %s %s%s",
+		     dist->list[j],
+		     output ? "out" : "in",
 		     dist->ifname ? dist->ifname : "",
 		     VTY_NEWLINE);
 	    write++;
 	  }
 
-	if (dist->list[DISTRIBUTE_OUT])
-	  {
-	    vty_out (vty, " distribute-list %s out %s%s", 
-
-		     dist->list[DISTRIBUTE_OUT],
-		     dist->ifname ? dist->ifname : "",
-		     VTY_NEWLINE);
-	    write++;
-	  }
-
-	if (dist->prefix[DISTRIBUTE_IN])
-	  {
-	    vty_out (vty, " distribute-list prefix %s in %s%s",
-		     dist->prefix[DISTRIBUTE_IN],
-		     dist->ifname ? dist->ifname : "",
-		     VTY_NEWLINE);
-	    write++;
-	  }
-
-	if (dist->prefix[DISTRIBUTE_OUT])
-	  {
-	    vty_out (vty, " distribute-list prefix %s out %s%s",
-		     dist->prefix[DISTRIBUTE_OUT],
+	for (j=0; j < DISTRIBUTE_MAX; j++)
+	  if (dist->prefix[j]) {
+	    output = j == DISTRIBUTE_OUT;
+	    vty_out (vty, " distribute-list prefix %s %s %s%s",
+		     dist->prefix[j],
+		     output ? "out" : "in",
 		     dist->ifname ? dist->ifname : "",
 		     VTY_NEWLINE);
 	    write++;
