How to use Libevent better?