Grid queries clean up

- Cleaned up grid queries implementation and tests.