More refactoring (combine _emit_tag_open() and _emit_tag_close())