Rewrite using libevent2.