Added better handling of empty formating, should resolve weird orphan text nodes.