Stream buffer class and some extra helper classes.