Fixes for some queries