improved debug information; added query formulate fallback