factor out charstream.