Some fixes to the tag replacement.  They now auto balance format tags.