Fixes to XML manipulation