Added query_location, other minor adjustments