small improvements to url parsing