Refactor query projection (also prepares for adding unwind)