Query commands

Ready for review.