Fix NodeList iteration errors and #addElement