Fix query request serialization.

(It's still pretty crappy.)