properly retains original referer string
properly handles empty referers/queries
properly handles referers with no possible parameters