private LibtorrentEngine() {
    log.info("Starting up libtorrent with version: " + LibTorrent.version());

    session = new Session();

    sessionSettings = SessionSettings.newDefaults();
    //		sessionSettings = SessionSettings.newMinMemoryUsage();
    //		sessionSettings = SessionSettings.newHighPerformanceSeed();

    //		sessionSettings.setTorrentConnectBoost(5);
    //		sessionSettings.setMinReconnectTime(1);
    //		session.stopDHT();

    sessionSettings.setActiveDownloads(5);
    sessionSettings.setActiveLimit(30);
    sessionSettings.setActiveSeeds(20);
    //		sessionSettings.setActiveDHTLimit(5);
    //		sessionSettings.setActiveTrackerLimit(30);

    sessionSettings.setUploadRateLimit(4000000);
    sessionSettings.setDownloadRateLimit(4000000);

    // These worked great!
    //		sessionSettings.setMixedModeAlgorithm(BandwidthMixedAlgo.);
    session.stopLSD();
    session.stopDHT();
    sessionSettings.announceDoubleNAT(true);
    sessionSettings.setPeerConnectTimeout(60);

    sessionSettings.useReadCache(false);
    sessionSettings.setMaxPeerlistSize(500);
    //		sessionSettings.setMaxPeerlistSize(20);
    sessionSettings.setHalgOpenLimit(5);

    //		sessionSettings.setDHTAnnounceInterval(3600);
    sessionSettings.setMinAnnounceInterval(3600);
    //		sessionSettings.setLocalServiceAnnounceInterval(3600);

    //		sessionSettings.setNoConnectPrivilegedPorts(true);

    sessionSettings.setTrackerBackoff(10);
    sessionSettings.setAutoManageInterval(600);
    sessionSettings.setRateLimitIPOverhead(true);
    //		sessionSettings.setTrackerReceiveTimeout(1);
    //		sessionSettings.setTrackerCompletionTimeout(1);
    //		sessionSettings.setStopTrackerTimeout(1);
    //		sessionSettings.setActiveLsdLimit(1);

    //		sessionSettings.setPeerTimeout(5);
    //		sessionSettings.setInactivityTimeout(5);

    //				sessionSettings.setMaxPeerlistSize(10);

    //		sessionSettings.setMaxPausedPeerlistSize(0);
    //				sessionSettings.setChokingAlgorithm(ChokingAlgorithm.RATE_BASED_CHOKER);
    //		sessionSettings.setCacheSize(999999);

    //		sessionSettings.setPeerConnectTimeout(35);

    //		sessionSettings.allowMultipleConnectionsPerIp(true);

    //		sessionSettings.setPeerTimeout(15);
    //				sessionSettings.setInactivityTimeout(30);

    //				sessionSettings.setConnectionsLimit(100000);

    //				sessionSettings.setConnectionSpeed(3000);

    // Performance settings

    //		sessionSettings.setAutoManageInterval(10);
    //		sessionSettings.setAutoScrapeInterval(5);
    //		sessionSettings.setMinAnnounceInterval(5);

    //		sessionSettings.setAnnounceToAllTrackers(false);
    //		sessionSettings.setDHTAnnounceInterval(5);
    //		sessionSettings.setMaxAllowedInRequestQueue(9999);
    //		sessionSettings.setUnchokeSlotsLimit(800);
    //		sessionSettings.setCacheExpiry(9999);

    //		sessionSettings.setAutoManagePreferSeeds(true);

    //		sessionSettings.setSendBufferLowWatermark(50);

    session.setSettings(sessionSettings);

    log.info("active seed limit: " + String.valueOf(session.getSettings().getActiveLimit()));

    this.scanInfos = new LinkedHashSet<ScanInfo>();
    this.infoHashToTorrentMap = new HashMap<String, TorrentHandle>();

    session.addListener(
        new AlertListener() {

          @Override
          public int[] types() {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public void alert(Alert<?> alert) {
            //				log.debug(alert.getType() + " - " + alert.getSwig().what() + " - " +
            // alert.getSwig().message());

          }
        });
  }
 public void updateSettings() {
   session.setSettings(sessionSettings);
   log.info("Libtorrent settings updated");
 }