diff --git a/includes/index_entity.inc b/includes/index_entity.inc
index d36b2f8..ea3c7d8 100644
--- a/includes/index_entity.inc
+++ b/includes/index_entity.inc
@@ -229,7 +229,14 @@ class SearchApiIndex extends Entity {
    * Remove all records of entities to index.
    */
   public function dequeueItems() {
-    $this->datasource()->stopTracking(array($this));
+    try {
+      $this->datasource()->stopTracking(array($this));
+    }
+    catch (SearchApiException $e) {
+      // When this datasource controller doesn't exist anymore, we're probably
+      // just deleting this index to reflect that – therefore, this exception is
+      // to be expected.
+    }
     _search_api_empty_cron_queue($this);
   }
 
diff --git a/search_api.module b/search_api.module
index 0c2e024..f8115c3 100644
--- a/search_api.module
+++ b/search_api.module
@@ -844,18 +844,31 @@ function search_api_search_api_item_type_info() {
  * Implements hook_modules_enabled().
  */
 function search_api_modules_enabled(array $modules) {
-  // New modules might offer additional entity types, invalidating the cached
-  // item type information.
+  // New modules might offer additional item types and service classes,
+  // invalidating the cached information.
   drupal_static_reset('search_api_get_item_type_info');
+  drupal_static_reset('search_api_get_service_info');
 }
 
 /**
  * Implements hook_modules_disabled().
  */
 function search_api_modules_disabled(array $modules) {
-  // The disabled modules might have offered entity types, which are now
-  // invalid. Therefore, clear the cached item type informaiton.
+  // The disabled modules might have offered item types, which are now
+  // invalid. Therefore, delete all indexes which don't have a valid item type
+  // anymore.
   drupal_static_reset('search_api_get_item_type_info');
+  $types = search_api_get_item_type_info();
+  $sql = 'SELECT id FROM {search_api_index} WHERE item_type NOT IN (:types)';
+  $indexes = db_query($sql, array(':types' => array_keys($types)));
+  entity_delete_multiple('search_api_index', $indexes->fetchCol());
+
+  // The same applies to service classes and servers.
+  drupal_static_reset('search_api_get_service_info');
+  $classes = search_api_get_service_info();
+  $sql = 'SELECT id FROM {search_api_server} WHERE class NOT IN (:classes)';
+  $servers = db_query($sql, array(':classes' => array_keys($classes)));
+  entity_delete_multiple('search_api_server', $servers->fetchCol());
 }
 
 /**
@@ -1480,7 +1493,7 @@ function search_api_get_data_type_info($type = NULL) {
  *
  * @see hook_search_api_service_info()
  *
- * @param $id
+ * @param string|null $id
  *   The ID of the service info to retrieve.
  *
  * @return array
@@ -1507,15 +1520,14 @@ function search_api_get_service_info($id = NULL) {
 /**
  * Returns information for either all item types, or a specific one.
  *
- * @param $type
+ * @param string|null $type
  *   If set, the item type whose information should be returned.
  *
- * @return
+ * @return array|null
  *   If $type is given, either an array containing the information of that item
  *   type, or NULL if it is unknown. Otherwise, an array keyed by type IDs
  *   containing the information for all item types. Item type information is
- *   formatted as specified by hook_search_api_item_type_info(), and has all
- *   optional fields filled with the defaults.
+ *   formatted as specified by hook_search_api_item_type_info().
  *
  * @see hook_search_api_item_type_info()
  */
