Fix cache lookup to make queries work