Support for optional query parts.

This is slowly becoming too complex.