epoll based version. Works OK, but performance may be improved