diff --git a/res/ais/clm.c b/res/ais/clm.c
index 9788c263ffe6db34c7220d543be379fead841092..219646f6a37bacf24ec2b0fbe0582619e612ec66 100644
--- a/res/ais/clm.c
+++ b/res/ais/clm.c
@@ -16,7 +16,7 @@
  * at the top of the source tree.
  */
 
-/*! 
+/*!
  * \file
  * \author Russell Bryant <russell@digium.com>
  *
@@ -24,7 +24,7 @@
  *
  * \arg http://www.openais.org/
  *
- * This file contains the code specific to the use of the CLM 
+ * This file contains the code specific to the use of the CLM
  * (Cluster Membership) Service.
  */
 
@@ -46,8 +46,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
 #include "asterisk/logger.h"
 
 SaClmHandleT clm_handle;
+static SaAisErrorT clm_init_res;
 
-static void clm_node_get_cb(SaInvocationT invocation, 
+static void clm_node_get_cb(SaInvocationT invocation,
 	const SaClmClusterNodeT *cluster_node, SaAisErrorT error);
 static void clm_track_cb(const SaClmClusterNotificationBufferT *notif_buffer,
 	SaUint32T num_members, SaAisErrorT error);
@@ -57,7 +58,7 @@ static const SaClmCallbacksT clm_callbacks = {
 	.saClmClusterTrackCallback   = clm_track_cb,
 };
 
-static void clm_node_get_cb(SaInvocationT invocation, 
+static void clm_node_get_cb(SaInvocationT invocation,
 	const SaClmClusterNodeT *cluster_node, SaAisErrorT error)
 {
 
@@ -114,7 +115,7 @@ static char *ais_clm_show_members(struct ast_cli_entry *e, int cmd, struct ast_c
 		               "=== ==> ID: 0x%x\n"
 		               "=== ==> Address: %s\n"
 		               "=== ==> Member: %s\n",
-		               (char *) node->nodeName.value, (int) node->nodeId, 
+		               (char *) node->nodeName.value, (int) node->nodeId,
 		               (char *) node->nodeAddress.value,
 		               node->member ? "Yes" : "No");
 
@@ -134,12 +135,10 @@ static struct ast_cli_entry ais_cli[] = {
 
 int ast_ais_clm_load_module(void)
 {
-	SaAisErrorT ais_res;
-
-	ais_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
-	if (ais_res != SA_AIS_OK) {
+	clm_init_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
+	if (clm_init_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n",
-			ais_err2str(ais_res));
+			ais_err2str(clm_init_res));
 		return -1;
 	}
 
@@ -152,11 +151,15 @@ int ast_ais_clm_unload_module(void)
 {
 	SaAisErrorT ais_res;
 
+	if (clm_init_res != SA_AIS_OK) {
+		return 0;
+	}
+
 	ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli));
 
 	ais_res = saClmFinalize(clm_handle);
 	if (ais_res != SA_AIS_OK) {
-		ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n", 
+		ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n",
 			ais_err2str(ais_res));
 		return -1;
 	}
diff --git a/res/ais/evt.c b/res/ais/evt.c
index 54a87935bd1cbb844e6f6414f9b7e299ac36459f..18c0be9881eeec2a4230bbe1e8a1a4cc67236634 100644
--- a/res/ais/evt.c
+++ b/res/ais/evt.c
@@ -16,7 +16,7 @@
  * at the top of the source tree.
  */
 
-/*! 
+/*!
  * \file
  * \author Russell Bryant <russell@digium.com>
  *
@@ -24,7 +24,7 @@
  *
  * \arg http://www.openais.org/
  *
- * This file contains the code specific to the use of the EVT 
+ * This file contains the code specific to the use of the EVT
  * (Event) Service.
  */
 
@@ -55,6 +55,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
 #endif
 
 SaEvtHandleT evt_handle;
+static SaAisErrorT evt_init_res;
 
 void evt_channel_open_cb(SaInvocationT invocation, SaEvtChannelHandleT channel_handle,
 	SaAisErrorT error);
@@ -63,7 +64,7 @@ void evt_event_deliver_cb(SaEvtSubscriptionIdT subscription_id,
 
 static const SaEvtCallbacksT evt_callbacks = {
 	.saEvtChannelOpenCallback  = evt_channel_open_cb,
-	.saEvtEventDeliverCallback = evt_event_deliver_cb, 
+	.saEvtEventDeliverCallback = evt_event_deliver_cb,
 };
 
 static const struct {
@@ -136,7 +137,7 @@ void evt_event_deliver_cb(SaEvtSubscriptionIdT sub_id,
 
 	ais_res = saEvtEventDataGet(event_handle, event, &len);
 	if (ais_res != SA_AIS_OK) {
-		ast_log(LOG_ERROR, "Error retrieving event payload: %s\n", 
+		ast_log(LOG_ERROR, "Error retrieving event payload: %s\n",
 			ais_err2str(ais_res));
 		return;
 	}
@@ -148,7 +149,7 @@ void evt_event_deliver_cb(SaEvtSubscriptionIdT sub_id,
 
 	if (!(event_dup = ast_malloc(len)))
 		return;
-	
+
 	memcpy(event_dup, event, len);
 
 	queue_event(event_dup);
@@ -195,8 +196,8 @@ static void ast_event_cb(const struct ast_event *ast_event, void *data)
 		ast_log(LOG_DEBUG, "Returning here\n");
 		return;
 	}
-	
-	ais_res = saClmClusterNodeGet(clm_handle, SA_CLM_LOCAL_NODE_ID, 
+
+	ais_res = saClmClusterNodeGet(clm_handle, SA_CLM_LOCAL_NODE_ID,
 		SA_TIME_ONE_SECOND, &local_node);
 	if (ais_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Error getting local node name: %s\n", ais_err2str(ais_res));
@@ -213,8 +214,8 @@ static void ast_event_cb(const struct ast_event *ast_event, void *data)
 	pattern_array.patternsNumber = 1;
 	pattern_array.patterns = &pattern;
 
-	/*! 
-	 * /todo Make retention time configurable 
+	/*!
+	 * /todo Make retention time configurable
 	 * /todo Make event priorities configurable
 	 */
 	ais_res = saEvtEventAttributesSet(event_handle, &pattern_array,
@@ -224,7 +225,7 @@ static void ast_event_cb(const struct ast_event *ast_event, void *data)
 		goto return_event_free;
 	}
 
-	ais_res = saEvtEventPublish(event_handle, 
+	ais_res = saEvtEventPublish(event_handle,
 		ast_event, ast_event_get_size(ast_event), &event_id);
 	if (ais_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Error publishing event: %s\n", ais_err2str(ais_res));
@@ -273,12 +274,12 @@ static char *ais_evt_show_event_channels(struct ast_cli_entry *e, int cmd, struc
 		               "=== Event Channel Name: %s\n", event_channel->name);
 
 		AST_LIST_TRAVERSE(&event_channel->publish_events, publish_event, entry) {
-			ast_cli(a->fd, "=== ==> Publishing Event Type: %s\n", 
+			ast_cli(a->fd, "=== ==> Publishing Event Type: %s\n",
 				type_to_filter_str(publish_event->type));
 		}
-		
+
 		AST_LIST_TRAVERSE(&event_channel->subscribe_events, subscribe_event, entry) {
-			ast_cli(a->fd, "=== ==> Subscribing to Event Type: %s\n", 
+			ast_cli(a->fd, "=== ==> Subscribing to Event Type: %s\n",
 				type_to_filter_str(subscribe_event->type));
 		}
 
@@ -353,7 +354,7 @@ static SaAisErrorT set_egress_subscription(struct event_channel *event_channel,
 	filter_array.filtersNumber = 1;
 	filter_array.filters = &filter;
 
-	ais_res = saEvtEventSubscribe(event_channel->handle, &filter_array, 
+	ais_res = saEvtEventSubscribe(event_channel->handle, &filter_array,
 		subscribe_event->id);
 
 	return ais_res;
@@ -425,7 +426,7 @@ static void build_event_channel(struct ast_config *cfg, const char *cat)
 	strcpy(event_channel->name, cat);
 	ast_copy_string((char *) sa_name.value, cat, sizeof(sa_name.value));
 	sa_name.length = strlen((char *) sa_name.value);
-	ais_res = saEvtChannelOpen(evt_handle, &sa_name, 
+	ais_res = saEvtChannelOpen(evt_handle, &sa_name,
 		SA_EVT_CHANNEL_PUBLISHER | SA_EVT_CHANNEL_SUBSCRIBER | SA_EVT_CHANNEL_CREATE,
 		SA_TIME_MAX, &event_channel->handle);
 	if (ais_res != SA_AIS_OK) {
@@ -477,7 +478,7 @@ static void load_config(void)
 		if (!strcasecmp(type, "event_channel")) {
 			build_event_channel(cfg, cat);
 		} else {
-			ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'\n", 
+			ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'\n",
 				filename, type);
 		}
 	}
@@ -532,22 +533,21 @@ static void destroy_event_channels(void)
 	struct event_channel *event_channel;
 
 	AST_RWLIST_WRLOCK(&event_channels);
-	while ((event_channel = AST_RWLIST_REMOVE_HEAD(&event_channels, entry)))
+	while ((event_channel = AST_RWLIST_REMOVE_HEAD(&event_channels, entry))) {
 		event_channel_destroy(event_channel);
+	}
 	AST_RWLIST_UNLOCK(&event_channels);
 }
 
 int ast_ais_evt_load_module(void)
 {
-	SaAisErrorT ais_res;
-
-	ais_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
-	if (ais_res != SA_AIS_OK) {
+	evt_init_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
+	if (evt_init_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Could not initialize eventing service: %s\n",
-			ais_err2str(ais_res));
+			ais_err2str(evt_init_res));
 		return -1;
 	}
-	
+
 	load_config();
 
 	ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli));
@@ -559,14 +559,18 @@ int ast_ais_evt_unload_module(void)
 {
 	SaAisErrorT ais_res;
 
+	if (evt_init_res != SA_AIS_OK) {
+		return 0;
+	}
+
 	destroy_event_channels();
 
 	ais_res = saEvtFinalize(evt_handle);
 	if (ais_res != SA_AIS_OK) {
-		ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n", 
+		ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n",
 			ais_err2str(ais_res));
 		return -1;
 	}
 
-	return 0;	
+	return 0;
 }