Tidied up libevent dispatch code. It was having issues with the unit tests.