Add replace-contents and clean up syntax use

-Added replace-contents it insert nodes into an element
-Cleaned up code to be more clear
-Be sure last replace-value called on a node wins out