Added guards around changes to stream modifiers.