Several fixes to XML parsing and writing.
Added logger control of exceptions.