Cleanup and adjustment for flattened XML