Factor gradients out of Query
minor refactoring
Merge pull request #49 from ku-fpg/gradient

Factor gradients out of Query