Remove unnecessary queries.