Moving some processing from extract_tag to insert_tag.