cleanup formatting
receive input stream, count data, return duplex stream