re-apply fixes by Brian to XML