Dynamic parts of URLs need to be encoded properly

Please review and merge.