added setElements for caching XPATH DOMElements. Misc. big-fixing and code-cleanup.