Add query encoding/decoding.
Refactor QueryStepList.
Add query substeps.