Fix bugs in stream usage.