Repare memory cleanup in xml parser