Fixed query execution bugs after IO overhaul.