Fixed client code to handle bytestreams