Improved root element handling