Fixes for queries