Query fixes