Fixes to query command