bug 6158; fixing replaceWith from throwing errors on non existant elements; fixing...