DomHelper refactored and compiled with closure, other minor fixes after code review