Undo a change which resulted in dangling FDs
Removed a hackish check for stdout in pump()
Made scoket protocol uniform

Also eliminated some control flow branches