further improvements to tag parser