void readParameters() {
    port = readIntParameter("PORT", 5900);

    String hexcookie = readParameter("COOKIE", true);
    // COOKIE is hexascii-encoded. Decode.
    if (hexcookie.length() != 32)
      fatalError("COOKIE parameter needs to be 32 hexdigits in length");
    cookieParam = new byte[16];
    for (int i = 0; i < 16; i++) {
      String hex = hexcookie.substring(i*2, i*2+2);
      Integer x = new Integer(Integer.parseInt(hex, 16));
      cookieParam[i] = x.byteValue();
    }

    String str;
    if (inAnApplet) {
      str = readParameter("Open New Window", false);
      if (str != null && str.equalsIgnoreCase("Yes"))
	inSeparateFrame = true;
    }

    // "Show Controls" set to "No" disables button panel.
    showControls = true;
    str = readParameter("Show Controls", false);
    if (str != null && str.equalsIgnoreCase("No"))
      showControls = false;

    // Do we continue showing desktop on remote disconnect?
    showOfflineDesktop = false;
    str = readParameter("Show Offline Desktop", false);
    if (str != null && str.equalsIgnoreCase("Yes"))
      showOfflineDesktop = true;

    // Fine tuning options.
    deferScreenUpdates = readIntParameter("Defer screen updates", 20);
    deferCursorUpdates = readIntParameter("Defer cursor updates", 10);
    deferUpdateRequests = readIntParameter("Defer update requests", 0);

    // Debugging options.
    debugStatsExcludeUpdates = readIntParameter("DEBUG_XU", 0);
    debugStatsMeasureUpdates = readIntParameter("DEBUG_CU", 0);
  }