String lookups generalized

Query lookups also simplified.