fix pipes, prepare for threaded input, output