Restructured insertBefore() and insertAfter()