Fix exception in toDom
Minor fixes