protected void changeRegistrySettings(boolean ensureCleanSession, boolean avoidProxy) throws IOException {
    	log.info("Modifying registry settings...");
    	HudsuckrSettings settings;
    	if (oldSettings == null) {
    		backupHudsuckrSettings();
    	}
    	if (!customPACappropriate) {
    		String proxyServer = "127.0.0.1:" + portDriversShouldContact;
            settings = new HudsuckrSettings(oldSettings.connection, true, true, false, false, proxyServer, "(null)", "(null)");
        } else {
            File proxyPAC = LauncherUtils.makeProxyPAC(customProxyPACDir, port, avoidProxy);

            String newURL = "file://" + proxyPAC.getAbsolutePath().replace('\\', '/');
            settings = new HudsuckrSettings(oldSettings.connection, true, false, true, false, "(null)", "(null)", newURL);
        }
    	runHudsuckr(settings.toStringArray());

        // Disabling automatic proxy caching
        // http://support.microsoft.com/?kbid=271361
        // Otherwise, *all* requests will go through our proxy, rather than just */selenium-server/* requests
        try {
            WindowsUtils.writeBooleanRegistryValue(RegKey.AUTOPROXY_RESULT_CACHE.key, false);
        } catch (WindowsRegistryException ex) {
            log.debug("Couldn't modify autoproxy result cache; this often fails on Vista, but it's merely a nice-to-have", ex);
        }
        
        // Disable caching of html
        try {
            WindowsUtils.writeStringRegistryValue(RegKey.MIME_EXCLUSION_LIST_FOR_CACHE.key, "multipart/mixed multipart/x-mixed-replace multipart/x-byteranges text/html");
        } catch (WindowsRegistryException ex) {
            log.debug("Couldn't disable caching of html; this often fails on Vista, but it's merely a nice-to-have", ex);
        }
        
        WindowsUtils.writeBooleanRegistryValue(RegKey.USERNAME_PASSWORD_DISABLE.key, false);

        // Disable pop-up blocking
        if (WindowsUtils.doesRegistryValueExist(RegKey.POPUP_MGR.key)) {
		    WindowsUtils.deleteRegistryValue(RegKey.POPUP_MGR.key);
		}
		if (RegKey.POPUP_MGR.type.equals(String.class)) {
		    WindowsUtils.writeStringRegistryValue(RegKey.POPUP_MGR.key, "no");
		} else {
		    WindowsUtils.writeBooleanRegistryValue(RegKey.POPUP_MGR.key, false);
		}

        WindowsUtils.writeBooleanRegistryValue(RegKey.WARN_ON_FORM_SUBMIT.key, false);

        // DGF Don't manage proxy settings the IE4 way; use hudsuckr instead
//        if (WindowsUtils.doesRegistryValueExist(RegKey.PROXY_OVERRIDE.key)) {
//            WindowsUtils.deleteRegistryValue(RegKey.PROXY_OVERRIDE.key);
//        }

        if (changeMaxConnections) {
            // need at least 1 xmlHttp connection per frame/window
            WindowsUtils.writeIntRegistryValue(RegKey.MAX_CONNECTIONS_PER_1_0_SVR.key, 256);
            WindowsUtils.writeIntRegistryValue(RegKey.MAX_CONNECTIONS_PER_1_1_SVR.key, 256);
        }
        
        // Hide pre-existing user cookies if -ensureCleanSession is set
        if (ensureCleanSession) {
          hidePreexistingCookies();
          deleteTemporaryInternetFiles();
        }

        // TODO Do we want to make these preferences configurable somehow?
        // TODO Disable security warnings
        // TODO Disable "do you want to remember this password?"
    }