Bug fix for compound queries and a header for easier debugging