More cleanup on URL parsing and unparsing