Updated to flatten and rename xml