Refactored Stream#encode_tag