Fixed Documents generated query errors