Rewrite URL parsing code to use urlparse.