general query fixes