Adding better error checking into xml parser. should also recognize self references