Remove dependency on libevent, add -pthread when necessary.