diff --git a/includes/drealty.connection.admin.inc b/includes/drealty.connection.admin.inc
index fa41132..aef283f 100644
--- a/includes/drealty.connection.admin.inc
+++ b/includes/drealty.connection.admin.inc
@@ -324,6 +324,7 @@ function drealty_activate_connection_form($form, &$form_state, $connection = NUL
         '#type' => 'submit',
         '#value' => t('Activate'),
       );
+      $dc->disconnect();
     } else {
       $error= $dc->rets->Error();
       drupal_set_message(t("drealty encountered an error: (Type: @type Code: @code Msg: @text)", array("@type" => $error['type'], "@code" => $error['code'], "@text" => $error['text'])), 'error');
@@ -332,8 +333,6 @@ function drealty_activate_connection_form($form, &$form_state, $connection = NUL
       );
     }
 
-
-    $dc->rets->disconnect();
   }
   return $form;
 }
@@ -671,6 +670,7 @@ function drealty_resource_configure_form($form, &$form_state, drealtyConnectionE
       }
     }
   }
+  $dc->disconnect();
 
   $form_state['has_images'] = $has_images;
 
diff --git a/includes/drealty.connection.inc b/includes/drealty.connection.inc
index 1c1355e..3f13c59 100644
--- a/includes/drealty.connection.inc
+++ b/includes/drealty.connection.inc
@@ -35,6 +35,15 @@ class drealtyConnection {
     $this->rets = new phRETS();
   }
 
+  public function __destruct() {
+    // If we're still connected, someone forgot to disconnect.
+    if ($this->rets && $this->connected) {
+      $backtrace = debug_backtrace();
+      watchdog('drealty', 'Connection to server still active, someone forgot it open in @func(). Attempting to disconnect.', array('@func' => $backtrace[1]['function']));
+      $this->disconnect();
+    }
+  }
+
   /**
    *
    * @param int $conid
@@ -115,6 +124,7 @@ class drealtyConnection {
       }
     } else {
       // connection was successful!
+      $this->connected = TRUE;
       return TRUE;
     }
   }
@@ -130,10 +140,13 @@ class drealtyConnection {
     if ($this->rets && $this->connected) {
       if ($this->rets->Disconnect()) {
         $this->connected = FALSE;
-        drush_log("Disconnected from RETS server.");
+        if (function_exists('drush_log')) {
+          drush_log("Disconnected from RETS server.");
+        }
         return TRUE;
       } else {
-        throw new drealty_rets_disconnect_exception('Error Disconnecting from the RETS Server.');
+        $error = $this->rets->Error();
+        throw new drealty_rets_disconnect_exception("Error Disconnecting from the RETS Server: (Type: {$error['type']} Code: {$error['code']} Msg: {$error['text']})");
       }
     }
   }
