Fix xml roundtrip bugs