diff --git a/README.txt b/README.txt
index 0fbde82..dedfd36 100644
--- a/README.txt
+++ b/README.txt
@@ -102,6 +102,15 @@ to $conf; memcache_servers and memcache_bins. The arrays follow this pattern:
    binS => clusterS
 )
 
+You can optionally assign a weight to each server, favoring one server more than
+another. For example, to make it 10 times more likely to store an item on
+server1 versus server2:
+
+'memcache_servers' => array(
+  server1:port => array('cluster' => cluster1, 'weight' => 10),
+  server2:port => array('cluster' => cluster2, 'weight' => 1'),
+)
+
 The bin/cluster/server model can be described as follows:
 
 - Servers are memcached instances identified by host:port.
diff --git a/dmemcache.inc b/dmemcache.inc
index 5f0b441..6661997 100644
--- a/dmemcache.inc
+++ b/dmemcache.inc
@@ -576,7 +576,17 @@ function dmemcache_stats($stats_bin = 'cache', $stats_type = 'default', $aggrega
         // passed to the Memcache memcache_get_extended_stats() function.
         elseif ($mc instanceof Memcache) {
           if ($stats_type == 'default' || $stats_type == '') {
-            $stats[$bin] = $mc->getExtendedStats();
+            $rc = $mc->getExtendedStats();
+            if (is_array($rc)) {
+              foreach ($rc as $server => $data) {
+                if (empty($data)) {
+                  unset($rc[$server]);
+                }
+              }
+              if (!empty($rc)) {
+                $stats[$bin] = $rc;
+              }
+            }
           }
           // If $slab isn't zero, then we are dumping the contents of a
           // specific cache slab.
@@ -769,14 +779,13 @@ function dmemcache_instance() {
  * @param string $server
  *   A server string of the format "localhost:11211" or
  *   "unix:///path/to/socket".
- * @param bool $connection
- *   TRUE or FALSE, whether the $memcache instance already has at least one
- *   open connection.
+ * @param integer $weight
+ *   Weighted probability of talking to this server.
  *
  * @return bool
  *   TRUE or FALSE if connection was successful.
  */
-function dmemcache_connect($memcache, $server, $connection) {
+function dmemcache_connect($memcache, $server, $weight) {
   static $memcache_persistent = NULL;
 
   $extension = dmemcache_extension();
@@ -786,15 +795,8 @@ function dmemcache_connect($memcache, $server, $connection) {
     register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php. Please review README.txt for proper configuration.', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
   }
 
+  $port_error = FALSE;
   if ($extension == 'Memcache') {
-    // Allow persistent connection via Memcache extension -- note that this
-    // module currently doesn't support persistent connections with the
-    // Memcached extension. See http://drupal.org/node/822316#comment-4427676
-    // for details.
-    if (!isset($memcache_persistent)) {
-      $memcache_persistent = variable_get('memcache_persistent', FALSE);
-    }
-
     // Support unix sockets of the format 'unix:///path/to/socket'.
     if ($host == 'unix') {
       // Use full protocol and path as expected by Memcache extension.
@@ -802,31 +804,7 @@ function dmemcache_connect($memcache, $server, $connection) {
       $port = 0;
     }
     else if (!isset($port)) {
-      register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php which does not include a port. Please review README.txt for proper configuration. You must specify both a server address and port such as "!ip" or "!host", or a unix socket such as "!socket".', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
-    }
-
-    // When using the PECL memcache extension, we must use ->(p)connect
-    // for the first connection.
-    if (!$connection) {
-      $track_errors = ini_set('track_errors', '1');
-      $php_errormsg = '';
-
-      // The Memcache extension requires us to use (p)connect for the first
-      // server we connect to.
-      if ($memcache_persistent) {
-        $rc = @$memcache->pconnect($host, $port);
-      }
-      else {
-        $rc = @$memcache->connect($host, $port);
-      }
-      if (!empty($php_errormsg)) {
-        register_shutdown_function('watchdog', 'memcache', 'Exception caught in dmemcache_connect while connecting to !host:!port: !msg', array('!host' => $host, '!port' => $port, '!msg' => $php_errormsg), WATCHDOG_WARNING);
-        $php_errormsg = '';
-      }
-      ini_set('track_errors', $track_errors);
-    }
-    else {
-      $rc = $memcache->addServer($host, $port, $memcache_persistent);
+      $port_error = TRUE;
     }
   }
   elseif ($extension == 'Memcached') {
@@ -837,9 +815,25 @@ function dmemcache_connect($memcache, $server, $connection) {
       $port = 0;
     }
     else if (!isset($port)) {
-      register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php which does not include a port. Please review README.txt for proper configuration. You must specify both a server address and port such as "!ip" or "!host", or a unix socket such as "!socket".', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
+      $port_error = TRUE;
+    }
+  }
+  if ($port_error) {
+    register_shutdown_function('watchdog', 'memcache', 'You have specified an invalid address of "!server" in settings.php which does not include a port. Please review README.txt for proper configuration. You must specify both a server address and port such as "!ip" or "!host", or a unix socket such as "!socket".', array('!server' => $server, '!ip' => t('127.0.0.1:11211'), '!host' => t('localhost:11211'), '!socket' => t('unix:///path/to/socket')), WATCHDOG_WARNING);
+  }
+
+  if ($extension == 'Memcache') {
+    // Allow persistent connection via Memcache extension -- note that this
+    // module currently doesn't support persistent connections with the
+    // Memcached extension. See http://drupal.org/node/822316#comment-4427676
+    // for details.
+    if (!isset($memcache_persistent)) {
+      $memcache_persistent = variable_get('memcache_persistent', FALSE);
     }
-    $rc = $memcache->addServer($host, $port);
+    $rc = $memcache->addServer($host, $port, $memcache_persistent, $weight);
+  }
+  elseif ($extension == 'Memcached') {
+    $rc = $memcache->addServer($host, $port, $weight);
   }
   else {
     $rc = FALSE;
@@ -923,13 +917,16 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
 
       // Track whether or not we've opened any memcache connections.
       $connection = FALSE;
-
       // Link all the servers to this cluster.
       foreach ($memcache_servers as $server => $c) {
-        if ($c == $cluster && !isset($failed_connections[$server])) {
-          $rc = dmemcache_connect($memcache, $server, $connection);
-          if ($rc !== FALSE) {
-            // We've made at least one successful connection.
+        $c = is_array($c) ? $c : array('cluster' => $c, 'weight' => 1);
+        if (!isset($c['weight']) || !is_int($c['weight']) || $c['weight'] < 1) {
+          $c['weight'] = 1;
+        }
+        if ($c['cluster'] == $cluster && !isset($failed_connections[$server])) {
+          $rc = dmemcache_connect($memcache, $server, $c['weight'], $connection);
+          if ($rc) {
+            // We've made at least one connection.
             $connection = TRUE;
           }
           else {
diff --git a/memcache-lock.inc b/memcache-lock.inc
index ef176df..7e3b3b6 100644
--- a/memcache-lock.inc
+++ b/memcache-lock.inc
@@ -12,7 +12,11 @@ require_once dirname(__FILE__) . '/dmemcache.inc';
 // @todo get rid of this conditional include as soon as this is done:
 // http://drupal.org/node/1225404
 $lock_file = dirname(__FILE__) . '/memcache-lock-code.inc';
-if (!dmemcache_object('semaphore')) {
+$mc = dmemcache_object('semaphore');
+// dmemcache_object always returns TRUE, we don't need these stats but it forces
+// us to try and connect to memcache. If this fails, we can't store locks in
+// memcache.
+if (!$mc->getStats()) {
   $lock_file = DRUPAL_ROOT . '/includes/lock.inc';
 }
 require_once $lock_file;
diff --git a/memcache.install b/memcache.install
index f57ace7..1064409 100644
--- a/memcache.install
+++ b/memcache.install
@@ -113,7 +113,11 @@ function memcache_requirements($phase) {
       $memcache_servers = variable_get('memcache_servers', array('127.0.0.1:11211' => 'default'));
       $memcache = dmemcache_instance();
       foreach ($memcache_servers as $server => $bin) {
-        if (dmemcache_connect($memcache, $server, FALSE) === FALSE) {
+        $bin = is_array($bin) ? $bin : array('cluster' => $bin, 'weight' => 1);
+        if (!isset($bin['weight']) || !is_int($bin['weight']) || $bin['weight'] < 1) {
+          $bin['weight'] = 1;
+        }
+        if (dmemcache_connect($memcache, $server, 1, FALSE) === FALSE) {
           $errors[] = $t('Failed to connect to memcached server instance at %server.', array('%server' => $server));
         }
         else {
