Make document.getElementsByTagname return a NodeList; consolidate element collection to collectElement; fix #1744