Minor improvements to URL handling