Fix issues with to_etree