modify makeArray and AdjustDocument

check if nodeList is already an array
modify the way nodes list get flattened