Factor out the stream handlers!