Refactored streams from C-style to a C++ class hierarchy.