Routines for dealing with data streams
