Move the query function to the cc file and make trace stuff work