Lots of upgrades, including adding p tag to empty text node.