Fix XML loading bugs