Made xml parsing a little more robust