Refactor query projection (also prepares for adding unwind)
Merge pull request #2588 from systay/new-query-projection

Refactor query projection