Make sure query string is kept intact

Fixes #710