Fix preserving URI query string. Closes gh-534.