Refactor the output pipe creation logic.

Slave output pipe creation logic is rewritten a bit to be more C++-ish
and less C-ish. Which is, of course, very good.
Get rid of 'worker' mentions everywhere.

Slave is a slave, not need to call it a worker, because it only messes
with the nomenclature and makes it harder to understand the logic.