Use eventfd instead of pipe, add proper cleanup code