Improve url decoding to involve fewer steps, and less copying