more improvements

pass with sanitizers and don't hold locks through poll