refactor CodedStream to istream and fd subclasses