Query bug fixes.