Fixed bug in  and forEach function. Removed usages of forEach in dom.js for performance