Completed a little part of query management

major work remains