Fix, and simplify url generation