diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 4706d535054cf9663c1d767b1c1b7540f576997e..d94603837ee652ffeba4473447efc73b6f4ab8b9 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -290,7 +290,9 @@ static struct ast_speech *find_speech(struct ast_channel *chan)
 		return NULL;
 	}
 
+	ast_channel_lock(chan);
 	datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
+	ast_channel_unlock(chan);
 	if (datastore == NULL) {
 		return NULL;
 	}
@@ -299,6 +301,35 @@ static struct ast_speech *find_speech(struct ast_channel *chan)
 	return speech;
 }
 
+/*!
+ * \internal
+ * \brief Destroy the speech datastore on the given channel.
+ *
+ * \param chan Channel to destroy speech datastore.
+ *
+ * \retval 0 on success.
+ * \retval -1 not found.
+ */
+static int speech_datastore_destroy(struct ast_channel *chan)
+{
+	struct ast_datastore *datastore;
+	int res;
+
+	ast_channel_lock(chan);
+	datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
+	if (datastore) {
+		ast_channel_datastore_remove(chan, datastore);
+	}
+	ast_channel_unlock(chan);
+	if (datastore) {
+		ast_datastore_free(datastore);
+		res = 0;
+	} else {
+		res = -1;
+	}
+	return res;
+}
+
 /* Helper function to find a specific speech recognition result by number and nbest alternative */
 static struct ast_speech_result *find_result(struct ast_speech_result *results, char *result_num)
 {
@@ -532,7 +563,9 @@ static int speech_create(struct ast_channel *chan, const char *data)
 	}
 	pbx_builtin_setvar_helper(chan, "ERROR", NULL);
 	datastore->data = speech;
+	ast_channel_lock(chan);
 	ast_channel_datastore_add(chan, datastore);
+	ast_channel_unlock(chan);
 
 	return 0;
 }
@@ -675,7 +708,6 @@ static int speech_background(struct ast_channel *chan, const char *data)
 	RAII_VAR(struct ast_format *, oldreadformat, NULL, ao2_cleanup);
 	char dtmf[AST_MAX_EXTENSION] = "";
 	struct timeval start = { 0, 0 }, current;
-	struct ast_datastore *datastore = NULL;
 	char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
 	const char *tmp2 = NULL;
 	struct ast_flags options = { 0 };
@@ -904,11 +936,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
 
 	/* See if it was because they hung up */
 	if (done == 3) {
-		/* Destroy speech structure */
-		ast_speech_destroy(speech);
-		datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
-		if (datastore != NULL)
-			ast_channel_datastore_remove(chan, datastore);
+		speech_datastore_destroy(chan);
 	} else {
 		/* Channel is okay so restore read format */
 		ast_set_read_format(chan, oldreadformat);
@@ -921,22 +949,10 @@ static int speech_background(struct ast_channel *chan, const char *data)
 /*! \brief SpeechDestroy() Dialplan Application */
 static int speech_destroy(struct ast_channel *chan, const char *data)
 {
-	int res = 0;
-	struct ast_speech *speech = find_speech(chan);
-	struct ast_datastore *datastore = NULL;
-
-	if (speech == NULL)
+	if (!chan) {
 		return -1;
-
-	/* Destroy speech structure */
-	ast_speech_destroy(speech);
-
-	datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
-	if (datastore != NULL) {
-		ast_channel_datastore_remove(chan, datastore);
 	}
-
-	return res;
+	return speech_datastore_destroy(chan);
 }
 
 static int unload_module(void)
diff --git a/funcs/func_frame_trace.c b/funcs/func_frame_trace.c
index dea21c2521632682eeabbe70aa994ee7f5cf7a29..3ad048d28f0788d2646f3da30b261339c3f0b767 100644
--- a/funcs/func_frame_trace.c
+++ b/funcs/func_frame_trace.c
@@ -185,6 +185,7 @@ static int frame_trace_helper(struct ast_channel *chan, const char *cmd, char *d
 			id = datastore->data;
 			ast_framehook_detach(chan, *id);
 			ast_channel_datastore_remove(chan, datastore);
+			ast_datastore_free(datastore);
 		}
 
 		if (!(datastore = ast_datastore_alloc(&frame_trace_datastore, NULL))) {
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index 85c188e8837bf73c221364a3dab6dfeecd27e93c..e4c3c76ed3c99155e50429214b0520a8caadacc8 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -1055,6 +1055,7 @@ void ast_jb_create_framehook(struct ast_channel *chan, struct ast_jb_conf *jb_co
 			id = datastore->data;
 			ast_framehook_detach(chan, *id);
 			ast_channel_datastore_remove(chan, datastore);
+			ast_datastore_free(datastore);
 		}
 		ast_channel_unlock(chan);
 		return;
@@ -1087,6 +1088,7 @@ void ast_jb_create_framehook(struct ast_channel *chan, struct ast_jb_conf *jb_co
 			id = datastore->data;
 			ast_framehook_detach(chan, *id);
 			ast_channel_datastore_remove(chan, datastore);
+			ast_datastore_free(datastore);
 		}
 
 		if (!(datastore = ast_datastore_alloc(&jb_datastore, NULL))) {
@@ -1112,6 +1114,4 @@ void ast_jb_create_framehook(struct ast_channel *chan, struct ast_jb_conf *jb_co
 		framedata = NULL;
 	}
 	ast_channel_unlock(chan);
-
-	return;
 }
diff --git a/main/channel.c b/main/channel.c
index 4ce4e916f4809aede94bed1ff958d9cf58212890..6a252a6991cab4899de431459e74d3048cd35c26 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -10415,10 +10415,7 @@ int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum
 
 	if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
 		suppress = datastore->data;
-		ao2_ref(suppress, +1);
-
 		suppress->direction |= direction;
-
 		return 0;
 	}
 
@@ -10450,13 +10447,12 @@ int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum
 		return -1;
 	}
 
+	/* and another ref for the datastore */
+	ao2_ref(suppress, +1);
 	datastore->data = suppress;
 
 	ast_channel_datastore_add(chan, datastore);
 
-	/* and another ref for the datastore */
-	ao2_ref(suppress, +1);
-
 	return 0;
 }
 
@@ -10484,6 +10480,7 @@ int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enu
 		/* Nothing left to suppress.  Bye! */
 		ast_framehook_detach(chan, suppress->framehook_id);
 		ast_channel_datastore_remove(chan, datastore);
+		ast_datastore_free(datastore);
 	}
 
 	return 0;