Implement some functionality in query.cpp
Documentation fixes