Improve parsing of tag names and attributes