Fix queries for incosistent programs