Basic code for streams: untested.