Fixed query problems