Add support for keys in query
Merge pull request #545 from marcosnils/key_in_query

Add support for keys in query

This only partially fixes the problem.  I'll try to address the other half.