It's great to see how the code you deleted here has a much simpler (and much more probably a correct one) implementation in libuv.