Clear detritus from query-string handling

The handling of metadata is still a bit ad hoc, but this is an
improvement, I think.

Change-Id: Ie49818c483bcc242a3b7688bee480537b58f57da
Merge "Clear detritus from query-string handling"