Changed event handlers to handle root delegate events. document.write now retains former head nodes.