Better replacement of all text nodes, resolving issue #2