Implements main query methods.