Refactored code a bit to better separation of library. Library can now be compiled without libevent.