Started a rewrite to use a custom streambuf.