added doc strings to explain lower-level stream manipulations