Refactor the stream pipe to use a detyped flow