diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index d6d1ff5c61319ccb507653720da1472b904cea5b..b1e23fc8109365d03a6abe1b5d3a06da1612c407 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -2336,7 +2336,7 @@ static int canvas_del_ab(t_canvas *x, t_symbol *name)
     t_ab_definition *abdef, *abdefpre;
     for(abdef = c->gl_abdefs, abdefpre = 0; abdef; abdefpre = abdef, abdef = abdef->ad_next)
     {
-        if(abdef->ad_name == name)
+        if(abdef->ad_name == name && !abdef->ad_numinstances)
         {
             if(abdefpre) abdefpre->ad_next = abdef->ad_next;
             else c->gl_abdefs = abdef->ad_next;
@@ -2541,14 +2541,12 @@ typedef struct _abdefs
 {
     t_object x_obj;
     t_canvas *x_canvas;
-    int x_od;
 } t_abdefs;
 
 static void *abdefs_new(void)
 {
     t_abdefs *x = (t_abdefs *)pd_new(abdefs_class);
     x->x_canvas = canvas_getcurrent();
-    x->x_od = 0;
     outlet_new(&x->x_obj, &s_list);
     return (x);
 }
@@ -2583,7 +2581,7 @@ static void abdefs_instances(t_abdefs *x, t_symbol *s)
         outlet_list(x->x_obj.ob_outlet, &s_list, 1, at);
     }
     else
-        pd_error(x, "couldn't find definition for '%s'", s->s_name);
+        error("abdefs: couldn't find definition for '%s'", s->s_name);
 }
 
 static void abdefs_del(t_abdefs *x, t_symbol *s)
@@ -2595,9 +2593,9 @@ static void abdefs_del(t_abdefs *x, t_symbol *s)
         post("abdefs: definition for '%s' has been deleted", s->s_name);
     }
     else if(abdef)
-        pd_error(x, "couldn't delete '%s', it has at least one instance", s->s_name);
+        error("abdefs: couldn't delete '%s', it has at least one instance", s->s_name);
     else
-        pd_error(x, "couldn't find definition for '%s'", s->s_name);
+        error("abdefs: couldn't find definition for '%s'", s->s_name);
 }
 
 static void abdefs_clean(t_abdefs *x)
@@ -2625,18 +2623,11 @@ static void abdefs_clean(t_abdefs *x)
             abdef = abdef->ad_next;
         }
     }
-    post("abdefs: a total of '%d' ab definitions with zero instances have been deleted", tot);
+    post("abdefs: a total of [%d] ab definitions with zero instances have been deleted", tot);
 }
 
 static void abdefs_menuopen(t_abdefs *x)
 {
-    if(x->x_od)
-    {
-        pd_error(x, "the dialog is already open");
-        return;
-    }
-    x->x_od = 1;
-
     char buf[MAXPDSTRING];
     t_canvas *c = canvas_getrootfor_ab(x->x_canvas);
     t_ab_definition *abdef;
@@ -2644,12 +2635,18 @@ static void abdefs_menuopen(t_abdefs *x)
     gui_start_vmess("gui_external_dialog", "s", gfx_tag);
     gui_s("[ab] definitions");
     gui_start_array();
-    gui_s("select the definitions you want to delete_hidden"); gui_i(0);
-    gui_s("name  |  #instances_hidden"); gui_i(0);
-    gui_s("----------------------_hidden"); gui_i(0);
+    gui_s("name  |  #instances   [delete?]_hidden"); gui_i(0);
+    gui_s("----------------------------------------_hidden"); gui_i(0);
+    if(!c->gl_abdefs)
+    {
+        gui_s("*no definitions*_hidden"); gui_i(0);
+    }
     for(abdef = c->gl_abdefs; abdef; abdef = abdef->ad_next)
     {
-        sprintf(buf, "%s  |  %d_toggle", abdef->ad_name->s_name, abdef->ad_numinstances);
+        if(abdef->ad_numinstances)
+            sprintf(buf, "%s  |  %d    _hidden", abdef->ad_name->s_name, abdef->ad_numinstances);
+        else
+            sprintf(buf, "%s  |  %d    _toggle", abdef->ad_name->s_name, 0);
         gui_s(buf); gui_i(0);
     }
     gui_end_array();
@@ -2658,41 +2655,26 @@ static void abdefs_menuopen(t_abdefs *x)
 
 static void abdefs_dialog(t_abdefs *x, t_symbol *s, int argc, t_atom *argv)
 {
-    if(!x->x_od)
-    {
-        pd_error(x, "deletion already performed, reopen the dialog if you want to delete more definitions");
-        return;
-    }
-
-    argc -= 3;
-    argv += 3;
+    argc -= 2;
+    argv += 2;
 
     t_canvas *c = canvas_getrootfor_ab(x->x_canvas);
     t_ab_definition *abdef, *abdefpre;
-    int tot = 0, del = 0;
+    int tot = 0;
     for(abdef = c->gl_abdefs, abdefpre = 0; abdef; )
     {
         if(atom_getfloat(argv))
         {
-            if(!abdef->ad_numinstances)
-            {
-                if(abdefpre) abdefpre->ad_next = abdef->ad_next;
-                else c->gl_abdefs = abdef->ad_next;
-                binbuf_free(abdef->ad_source);
-                freebytes(abdef->ad_dep, sizeof(t_ab_definition*)*abdef->ad_numdep);
-                freebytes(abdef->ad_deprefs, sizeof(int)*abdef->ad_numdep);
-                freebytes(abdef, sizeof(t_ab_definition));
-                if(abdefpre) abdef = abdefpre->ad_next;
-                else abdef = c->gl_abdefs;
-                del++;
-            }
-            else
-            {
-                pd_error(x, "couldn't delete '%s', it has at least one instance",
-                    abdef->ad_name->s_name);
-                abdefpre = abdef;
-                abdef = abdef->ad_next;
-            }
+            if(abdef->ad_numinstances) bug("abdefs_dialog");
+
+            if(abdefpre) abdefpre->ad_next = abdef->ad_next;
+            else c->gl_abdefs = abdef->ad_next;
+            binbuf_free(abdef->ad_source);
+            freebytes(abdef->ad_dep, sizeof(t_ab_definition*)*abdef->ad_numdep);
+            freebytes(abdef->ad_deprefs, sizeof(int)*abdef->ad_numdep);
+            freebytes(abdef, sizeof(t_ab_definition));
+            if(abdefpre) abdef = abdefpre->ad_next;
+            else abdef = c->gl_abdefs;
             tot++;
         }
         else
@@ -2703,9 +2685,10 @@ static void abdefs_dialog(t_abdefs *x, t_symbol *s, int argc, t_atom *argv)
         argv++;
     }
 
-    x->x_od = 0;
     if(tot)
-        post("abdefs: a total of '%d' ab definitions with zero instances have been deleted", del);
+        post("abdefs: a total of [%d] ab definitions with zero instances have been deleted", tot);
+
+    gfxstub_deleteforkey(x);
 }
 
 /* ------------------------------- declare ------------------------ */