diff --git a/main/pbx.c b/main/pbx.c
index 9cffae8ef675b27751f1d41911e46f60b98028e0..650b0d9d99effd303cc604acd213b42d2de0e40a 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5433,7 +5433,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_
 	struct ast_hint *hint;
 	struct ast_exten *exten;
 	int length;
-	struct ast_state_cb *thiscb, *prevcb;
+	struct ast_state_cb *thiscb;
 	struct ast_hashtab_iter *iter;
 	
 	/* it is very important that this function hold the hint list lock _and_ the conlock
@@ -5451,7 +5451,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_
 	begintime = ast_tvnow();
 	ast_rdlock_contexts();
 	iter = ast_hashtab_start_traversal(contexts_table);
-	while ((tmp=ast_hashtab_next(iter))) {
+	while ((tmp = ast_hashtab_next(iter))) {
 		context_merge(extcontexts, exttable, tmp, registrar);
 	}
 	ast_hashtab_end_traversal(iter);
@@ -5506,11 +5506,11 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_
 		if (!exten || !hint) {
 			/* this hint has been removed, notify the watchers */
 			while ((thiscb = AST_LIST_REMOVE_HEAD(&this->callbacks, entry))) {
-				prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data);
-				ast_free(prevcb);
+				thiscb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, thiscb->data);
+				ast_free(thiscb);
 			}
 		} else {
-			AST_LIST_INSERT_TAIL(&this->callbacks, thiscb, entry);
+			AST_LIST_APPEND_LIST(&hint->callbacks, &this->callbacks, entry);
 			hint->laststate = this->laststate;
 		}
 		ast_free(this);