Simplified code for keeping query string vars intact

Follow-up to 624e8fb59ad0ab500a1c069c5661b1b006325aa7.