Simplify pipe management

We don't need to write perl like C.