Index: perl/lib/BarnOwl.pm
===================================================================
--- perl/lib/BarnOwl.pm	(revision 9179fd71fd47ed199f7576349a03ba4de77a8683)
+++ perl/lib/BarnOwl.pm	(revision bcde7926f64b37bec0e1c92962e8110187f58242)
@@ -166,6 +166,7 @@
 read from C<FD>.
 
-C<add_dispatch> has been deprecated in favor of C<add_io_dispatch>,
-and is now a wrapper for it called with C<mode> set to C<'r'>.
+C<add_dispatch> has been deprecated in favor of C<AnyEvent>, and is
+now a wrapper for C<add_io_dispatch> called with C<mode> set to
+C<'r'>.
 
 =cut
@@ -181,6 +182,5 @@
 Remove a file descriptor previously registered via C<add_dispatch>
 
-C<remove_dispatch> has been deprecated in favor of
-C<remove_io_dispatch>.
+C<remove_dispatch> has been deprecated in favor of C<AnyEvent>.
 
 =cut
@@ -197,5 +197,9 @@
 registered, the old one is removed.
 
-=cut
+C<add_io_dispatch> has been deprecated in favor of C<AnyEvent>.
+
+=cut
+
+our %_io_dispatches;
 
 sub add_io_dispatch {
@@ -203,11 +207,15 @@
     my $modeStr = shift;
     my $cb = shift;
-    my $mode = 0;
-
-    $mode |= 0x1 if ($modeStr =~ /r/i); # Read
-    $mode |= 0x2 if ($modeStr =~ /w/i); # Write
-    if ($mode) {
-        $mode |= 0x4;                  # Exceptional
-        BarnOwl::Internal::add_io_dispatch($fd, $mode, $cb);
+    my @modes;
+
+    push @modes, 'r' if $modeStr =~ /r/i; # Read
+    push @modes, 'w' if $modeStr =~ /w/i; # Write
+    if (@modes) {
+	BarnOwl::remove_io_dispatch($fd);
+	for my $mode (@modes) {
+	    push @{$_io_dispatches{$fd}}, AnyEvent->io(fh => $fd,
+						       poll => $mode,
+						       cb => $cb);
+	}
     } else {
         die("Invalid I/O Dispatch mode: $modeStr");
@@ -218,4 +226,14 @@
 
 Remove a file descriptor previously registered via C<add_io_dispatch>
+
+C<remove_io_dispatch> has been deprecated in favor of C<AnyEvent>.
+
+=cut
+
+sub remove_io_dispatch {
+    my $fd = shift;
+    undef $_ foreach @{$_io_dispatches{$fd}};
+    delete $_io_dispatches{$fd};
+}
 
 =head2 create_style NAME OBJECT
Index: perlconfig.c
===================================================================
--- perlconfig.c	(revision 074bdaa6d33d340b3da12b08994f54e70986e9d5)
+++ perlconfig.c	(revision bcde7926f64b37bec0e1c92962e8110187f58242)
@@ -548,9 +548,4 @@
 }
 
-void owl_perlconfig_io_dispatch_destroy(const owl_io_dispatch *d)
-{
-  SvREFCNT_dec(d->data);
-}
-
 void owl_perlconfig_edit_callback(owl_editwin *e)
 {
@@ -587,27 +582,2 @@
   SvREFCNT_dec(v);
 }
-
-void owl_perlconfig_io_dispatch(const owl_io_dispatch *d, void *data)
-{
-  SV *cb = data;
-  dSP;
-  if(cb == NULL) {
-    owl_function_error("Perl callback is NULL!");
-    return;
-  }
-
-  ENTER;
-  SAVETMPS;
-
-  PUSHMARK(SP);
-  PUTBACK;
-
-  call_sv(cb, G_DISCARD|G_EVAL);
-
-  if(SvTRUE(ERRSV)) {
-    owl_function_error("%s", SvPV_nolen(ERRSV));
-  }
-
-  FREETMPS;
-  LEAVE;
-}
Index: perlglue.xs
===================================================================
--- perlglue.xs	(revision 074bdaa6d33d340b3da12b08994f54e70986e9d5)
+++ perlglue.xs	(revision bcde7926f64b37bec0e1c92962e8110187f58242)
@@ -326,10 +326,4 @@
 		g_free(rv);
 
-void
-remove_io_dispatch(fd)
-	int fd
-	CODE:
-	owl_select_remove_perl_io_dispatch(fd);
-
 AV*
 all_filters()
@@ -507,12 +501,4 @@
 				      ival);
 
-void
-add_io_dispatch(fd, mode, cb)
-	int fd
-	int mode
-	SV * cb
-	CODE:
-	owl_select_add_perl_io_dispatch(fd, mode, newSVsv(cb));
-
 MODULE = BarnOwl		PACKAGE = BarnOwl::Editwin
 
Index: select.c
===================================================================
--- select.c	(revision 074bdaa6d33d340b3da12b08994f54e70986e9d5)
+++ select.c	(revision bcde7926f64b37bec0e1c92962e8110187f58242)
@@ -175,44 +175,4 @@
 };
 
-int owl_select_add_perl_io_dispatch(int fd, int mode, SV *cb)
-{
-  const owl_io_dispatch *d = owl_select_find_valid_io_dispatch_by_fd(fd);
-  if (d != NULL && d->callback != owl_perlconfig_io_dispatch) {
-    /* Don't mess with non-perl dispatch functions from here. */
-    return 1;
-  }
-  /* Also remove any invalidated perl dispatch functions that may have
-   * stuck around. */
-  owl_select_remove_perl_io_dispatch(fd);
-  owl_select_add_io_dispatch(fd, mode, owl_perlconfig_io_dispatch, owl_perlconfig_io_dispatch_destroy, cb);
-  return 0;
-}
-
-static owl_io_dispatch *owl_select_find_perl_io_dispatch(int fd)
-{
-  int i, len;
-  const owl_list *dl;
-  owl_io_dispatch *d;
-  dl = owl_global_get_io_dispatch_list(&g);
-  len = owl_list_get_size(dl);
-  for(i = 0; i < len; i++) {
-    d = owl_list_get_element(dl, i);
-    if (d->fd == fd && d->callback == owl_perlconfig_io_dispatch)
-      return d;
-  }
-  return NULL;
-}
-
-int owl_select_remove_perl_io_dispatch(int fd)
-{
-  owl_io_dispatch *d = owl_select_find_perl_io_dispatch(fd);
-  if (d != NULL) {
-    /* Only remove perl io dispatchers from here. */
-    owl_select_remove_io_dispatch(d);
-    return 0;
-  }
-  return 1;
-}
-
 void owl_select_init(void)
 {
