Clean up tag parsing a bit.