Improvements to url handling