Support for arbitrary root node name
Big code cleanup