Make DOM creation keep references to the before and after positions in the DOM. This fixes a few issues with DOM nodes appearing and disappearing.