diff --git a/apps/app_dial.c b/apps/app_dial.c
index 3a1f1231281f0476718a16c18f2747bc64f8103f..ee7c41f59a8d9b2fd01d67db061a55aaf92d9c3a 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1791,20 +1791,20 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
 
 		if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) {
 			int autoloopflag;
+			int found;
 			strcpy(peer->exten, "h");
 			peer->priority = 1;
 			autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP);	/* save value to restore at the end */
 			ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
 			
-			while (ast_exists_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num)) {
-				if ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num))) {
-					/* Something bad happened, or a hangup has been requested. */
-					ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
-					ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
-					break;
-				}
+			while ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num, &found,1))) {
 				peer->priority++;
 			}
+			if (found && res) {
+				/* Something bad happened, or a hangup has been requested. */
+				ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
+				ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
+			}
 			ast_set2_flag(peer, autoloopflag, AST_FLAG_IN_AUTOLOOP);  /* set it back the way it was */
 		}
 		if (res != AST_PBX_NO_HANGUP_PEER) {
diff --git a/apps/app_exec.c b/apps/app_exec.c
index 12b91a48824c31185bf0263f3dbeb619bc99ecb2..048c33851d83cbaf5d4178dd6ef7ba6205441274 100644
--- a/apps/app_exec.c
+++ b/apps/app_exec.c
@@ -92,7 +92,7 @@ static char *execif_descrip =
 static int exec_exec(struct ast_channel *chan, void *data)
 {
 	int res = 0;
-	char *s, *appname, *endargs, args[MAXRESULT] = "";
+	char *s, *appname, *endargs, args[MAXRESULT];
 	struct ast_app *app;
 
 	if (ast_strlen_zero(data))
@@ -122,7 +122,7 @@ static int exec_exec(struct ast_channel *chan, void *data)
 static int tryexec_exec(struct ast_channel *chan, void *data)
 {
 	int res = 0;
-	char *s, *appname, *endargs, args[MAXRESULT] = "";
+	char *s, *appname, *endargs, args[MAXRESULT];
 	struct ast_app *app;
 
 	if (ast_strlen_zero(data))
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 32e9d2d219413df4233a8f3e2996ecaa602cfb29..07284cabc9bb6cb58114c95b6e76521fe0049ec9 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -271,6 +271,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
 	while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
 		struct ast_context *c;
 		struct ast_exten *e;
+		int foundx;
 		runningapp[0] = '\0';
 		runningdata[0] = '\0';
 
@@ -299,7 +300,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
 		/* Reset the macro depth, if it was changed in the last iteration */
 		pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
 
-		if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num))) {
+		if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num, &foundx,1))) {
 			/* Something bad happened, or a hangup has been requested. */
 			if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
 		    	(res == '*') || (res == '#')) {
@@ -330,7 +331,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
 			gosub_level++;
 			ast_debug(1, "Incrementing gosub_level\n");
 		} else if (!strcasecmp(runningapp, "GOSUBIF")) {
-			char tmp2[1024] = "", *cond, *app, *app2 = tmp2;
+			char tmp2[1024], *cond, *app, *app2 = tmp2;
 			pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
 			cond = strsep(&app2, "?");
 			app = strsep(&app2, ":");
@@ -353,7 +354,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
 			ast_debug(1, "Decrementing gosub_level\n");
 		} else if (!strncasecmp(runningapp, "EXEC", 4)) {
 			/* Must evaluate args to find actual app */
-			char tmp2[1024] = "", *tmp3 = NULL;
+			char tmp2[1024], *tmp3 = NULL;
 			pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
 			if (!strcasecmp(runningapp, "EXECIF")) {
 				tmp3 = strchr(tmp2, '|');
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index bb352dc3fadd3f84d9d3776b3982969644848e2b..50300a90b6475e5b6be8338be9ea18eed13d6b21 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1025,7 +1025,6 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
 
 		ast_debug(4, "-_-_- Fromaddress template: %s\n", fromaddress);
 		if ((passdata = alloca(vmlen))) {
-			memset(passdata, 0, vmlen);
 			pbx_substitute_variables_helper(ast, fromaddress, passdata, vmlen);
 			len_passdata = strlen(passdata) * 2 + 3;
 			passdata2 = alloca(len_passdata);
@@ -1050,7 +1049,6 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
 		char *passdata;
 		int vmlen = strlen(template->subject) * 3 + 200;
 		if ((passdata = alloca(vmlen))) {
-			memset(passdata, 0, vmlen);
 			pbx_substitute_variables_helper(ast, template->subject, passdata, vmlen);
 			fprintf(p, "Subject: %s\n", passdata);
 		} else {
@@ -1082,7 +1080,6 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
 		char *passdata;
 		int vmlen = strlen(template->body)*3 + 200;
 		if ((passdata = alloca(vmlen))) {
-			memset(passdata, 0, vmlen);
 			pbx_substitute_variables_helper(ast, template->body, passdata, vmlen);
 			ast_debug(3, "Message now: %s\n-----\n", passdata);
 			fprintf(p, "%s\n", passdata);
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 13c25d8c7823cb072b9b93c7c0093ef02a3b9943..3c4ef97bc9882612750caa674fffbe2b85c94065 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -220,7 +220,7 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
 {
 	pthread_t thread;
 	struct mixmonitor *mixmonitor;
-	char postprocess2[1024] = "";
+	char postprocess2[1024];
 	size_t len;
 
 	len = sizeof(*mixmonitor) + strlen(chan->name) + strlen(filename) + 2;
@@ -235,7 +235,6 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
 				*p2 = '$';
 			}
 		}
-
 		pbx_substitute_variables_helper(chan, p1, postprocess2, sizeof(postprocess2) - 1);
 		if (!ast_strlen_zero(postprocess2))
 			len += strlen(postprocess2) + 1;
diff --git a/apps/app_playback.c b/apps/app_playback.c
index 6754d08487f63717d4a87e22dd37f463ae26c8c7..cb49b36ad643a64cbae4989b0ce961eb48b65108 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -202,7 +202,6 @@ static int do_say(say_args_t *a, const char *s, const char *options, int depth)
 		ast_trim_blanks(x);
 
 		/* replace variables */
-		memset(fn, 0, sizeof(fn)); /* XXX why isn't done in pbx_substitute_variables_helper! */
 		pbx_substitute_variables_varshead(&head, x, fn, sizeof(fn));
 		ast_log(LOG_WARNING, "doing [%s]\n", fn);
 
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 5ac4c26fb65e54874e06188bc2d8040fcc011568..92374f8766b40e1ceeb8555a8f411624efdb28e3 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2978,7 +2978,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
 					if (p == tmpid2 + sizeof(tmpid2))
 						tmpid2[sizeof(tmpid2) - 1] = '\0';
 
-					memset(tmpid, 0, sizeof(tmpid));
 					pbx_substitute_variables_helper(qe->chan, tmpid2, tmpid, sizeof(tmpid) - 1);
 				}
 
@@ -3005,7 +3004,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
 					if (p == meid2 + sizeof(meid2))
 						meid2[sizeof(meid2) - 1] = '\0';
 
-					memset(meid, 0, sizeof(meid));
 					pbx_substitute_variables_helper(qe->chan, meid2, meid, sizeof(meid) - 1);
 				}
 	
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 7d63b961ecf861a4c4394929320da3802693cdfb..14831eb07ef8b80622a1186d0151d2662f1e8391 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -6936,7 +6936,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
 		struct ast_hostent ahp;
 		struct hostent *hp;
 		struct in_addr ia;
-		char hisip[100] = "", nodeip[100];
+		char hisip[100], nodeip[100];
 		const char *val;
 		char *s, *s1, *s2;
 
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index fa4eb11c41134c82ece7f4e75f9be1c0ae834bab..fe65abd8c8a16ded2e7f90d7f468969d04933068 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -119,7 +119,6 @@ static int custom_log(struct ast_cdr *cdr)
 	if (ast_strlen_zero(master))
 		return 0;
 
-	memset(buf, 0 , sizeof(buf));
 	/* Quite possibly the first use of a static struct ast_channel, we need it so the var funcs will work */
 	memset(&dummy, 0, sizeof(dummy));
 	dummy.cdr = cdr;
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index 6e3dd87a372d837d41281899ada07a4a92e07330..4fa66b560c88ec2d565edce00292fef3a78f90c0 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -143,7 +143,6 @@ static int manager_log(struct ast_cdr *cdr)
 	ast_strftime(strEndTime, sizeof(strEndTime), DATE_FORMAT, &timeresult);
 
 	/* Custom fields handling */
-	memset(buf, 0 , sizeof(buf));
 	if (customfields != NULL && customfields->used > 0) {
 		memset(&dummy, 0, sizeof(dummy));
 		dummy.cdr = cdr;
diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c
index c6eb8b5ba4710252531ecc02f0cccb371e52d0fd..26ec6ff194d8a3a1a3d8fab7ae465a0f207471cc 100644
--- a/cdr/cdr_sqlite3_custom.c
+++ b/cdr/cdr_sqlite3_custom.c
@@ -158,7 +158,7 @@ static int sqlite3_log(struct ast_cdr *cdr)
 
 	{ /* Make it obvious that only sql_cmd should be used outside of this block */
 		char *sql_tmp_cmd;
-		char sql_insert_cmd[2048] = "";
+		char sql_insert_cmd[2048];
 		sql_tmp_cmd = sqlite3_mprintf("INSERT INTO %q (%q) VALUES (%q)", table, columns, values);
 		dummy.cdr = cdr;
 		pbx_substitute_variables_helper(&dummy, sql_tmp_cmd, sql_insert_cmd, sizeof(sql_insert_cmd) - 1);
diff --git a/funcs/func_cut.c b/funcs/func_cut.c
index 82a564b42c2c83a43083a1de3a7add2025a33a3b..cf19816272b5469fc139d1944bac481423b273c3 100644
--- a/funcs/func_cut.c
+++ b/funcs/func_cut.c
@@ -141,7 +141,6 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
 
 		if (tmp) {
 			snprintf(tmp, strlen(args.varname) + 4, "${%s}", args.varname);
-			memset(varvalue, 0, sizeof(varvalue));
 		} else {
 			return ERROR_NOMEM;
 		}
diff --git a/funcs/func_logic.c b/funcs/func_logic.c
index aff358c249061265b91b1a5e15a0a5352f473747..4093be80015623604ae6e0c2cc668c9a5c76c888 100644
--- a/funcs/func_logic.c
+++ b/funcs/func_logic.c
@@ -157,7 +157,6 @@ static int acf_import(struct ast_channel *chan, const char *cmd, char *data, cha
 		AST_APP_ARG(varname);
 	);
 	AST_STANDARD_APP_ARGS(args, data);
-	memset(buf, 0, len);
 
 	if (!ast_strlen_zero(args.varname)) {
 		struct ast_channel *chan2 = ast_get_channel_by_name_locked(args.channel);
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 069eaf7cd539e6a8c503f746b977e69529190ccd..a2f895b2e810ab41717b2dd0425e5f7106664874 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -138,7 +138,7 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co
 {
 	struct odbc_obj *obj = NULL;
 	struct acf_odbc_query *query;
-	char *t, buf[2048]="", varname[15];
+	char *t, buf[2048], varname[15];
 	int i, dsn, bogus_chan = 0;
 	AST_DECLARE_APP_ARGS(values,
 		AST_APP_ARG(field)[100];
@@ -256,7 +256,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
 {
 	struct odbc_obj *obj = NULL;
 	struct acf_odbc_query *query;
-	char sql[2048] = "", varname[15], colnames[2048] = "", rowcount[12] = "-1";
+	char sql[2048], varname[15], colnames[2048] = "", rowcount[12] = "-1";
 	int res, x, y, buflen = 0, escapecommas, rowlimit = 1, dsn, bogus_chan = 0;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(field)[100];
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index f4869f4da98c5d619a7fbf737c376777b70776fe..0ed4bc159255d63009a74eb4b618d37ee06aa75b 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -48,7 +48,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 static int function_fieldqty(struct ast_channel *chan, const char *cmd,
 			     char *parse, char *buf, size_t len)
 {
-	char *varsubst, varval[8192] = "", *varval2 = varval;
+	char *varsubst, varval[8192], *varval2 = varval;
 	int fieldcount = 0;
 	AST_DECLARE_APP_ARGS(args,
 			     AST_APP_ARG(varname);
@@ -734,8 +734,6 @@ static struct ast_custom_function strptime_function = {
 static int function_eval(struct ast_channel *chan, const char *cmd, char *data,
 			 char *buf, size_t len)
 {
-	memset(buf, 0, len);
-
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<string>)\n");
 		return -1;
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index 6faea62bec22a5fe08ceb43e406a5abd35105888..417b515095ed2877c8b2c0c6b4ff9510f1e0be84 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -522,7 +522,7 @@ int ast_extension_close(const char *pattern, const char *data, int needmore);
  * \retval -1 on failure.
  */
 int ast_spawn_extension(struct ast_channel *c, const char *context, 
-	const char *exten, int priority, const char *callerid);
+      const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn);
 
 /*! 
  * \brief Add a context include
diff --git a/main/logger.c b/main/logger.c
index 82badbb9262dfe4ae0098fe8db56379b73a1de4e..4f16852345c6d6953d429d6f8e44435c54de06a2 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -505,7 +505,7 @@ static int rotate_file(const char *filename)
 
 	if (!ast_strlen_zero(exec_after_rotate)) {
 		struct ast_channel *c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Logger/rotate");
-		char buf[512] = "";
+		char buf[512];
 		pbx_builtin_setvar_helper(c, "filename", filename);
 		pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf));
 		system(buf);
diff --git a/main/pbx.c b/main/pbx.c
index 2910219ed2702d44b33ce8fc9972c48c9b49f677..a3e82481c23d16bf19fff8f7a9f35eb24e168dc4 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1618,8 +1618,7 @@ int ast_func_write(struct ast_channel *chan, const char *function, const char *v
 
 static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int count)
 {
-	/* Substitutes variables into cp2, based on string cp1, and assuming cp2 to be
-	   zero-filled */
+	/* Substitutes variables into cp2, based on string cp1, cp2 NO LONGER NEEDS TO BE ZEROED OUT!!!!  */
 	char *cp4;
 	const char *tmp, *whereweare;
 	int length, offset, offset2, isfunction;
@@ -1628,7 +1627,8 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 	char *nextvar, *nextexp, *nextthing;
 	char *vars, *vare;
 	int pos, brackets, needsub, len;
-
+	
+	*cp2 = 0; /* just in case nothing ends up there */
 	whereweare=tmp=cp1;
 	while (!ast_strlen_zero(whereweare) && count) {
 		/* Assume we're copying the whole remaining string */
@@ -1662,6 +1662,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 			count -= pos;
 			cp2 += pos;
 			whereweare += pos;
+			*cp2 = 0;
 		}
 
 		if (nextvar) {
@@ -1702,7 +1703,6 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 				if (!ltmp)
 					ltmp = alloca(VAR_BUF_SIZE);
 
-				memset(ltmp, 0, VAR_BUF_SIZE);
 				pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1);
 				vars = ltmp;
 			} else {
@@ -1746,6 +1746,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 				memcpy(cp2, cp4, length);
 				count -= length;
 				cp2 += length;
+				*cp2 = 0;
 			}
 		} else if (nextexp) {
 			/* We have an expression.  Find the start and end, and determine
@@ -1789,7 +1790,6 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 				if (!ltmp)
 					ltmp = alloca(VAR_BUF_SIZE);
 
-				memset(ltmp, 0, VAR_BUF_SIZE);
 				pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1);
 				vars = ltmp;
 			} else {
@@ -1802,6 +1802,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 				ast_debug(1, "Expression result is '%s'\n", cp2);
 				count -= length;
 				cp2 += length;
+				*cp2 = 0;
 			}
 		}
 	}
@@ -1820,7 +1821,6 @@ void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1,
 static void pbx_substitute_variables(char *passdata, int datalen, struct ast_channel *c, struct ast_exten *e)
 {
 	const char *tmp;
-	memset(passdata, 0, datalen);
 
 	/* Nothing more to do */
 	if (!e->data)
@@ -1847,8 +1847,8 @@ static void pbx_substitute_variables(char *passdata, int datalen, struct ast_cha
  * \retval  -1 on failure.
  */
 static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
-	const char *context, const char *exten, int priority,
-	const char *label, const char *callerid, enum ext_match_t action)
+  const char *context, const char *exten, int priority,
+  const char *label, const char *callerid, enum ext_match_t action, int *found, int combined_find_spawn)
 {
 	struct ast_exten *e;
 	struct ast_app *app;
@@ -1857,10 +1857,14 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
 	char passdata[EXT_DATA_SIZE];
 
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
-
+	
 	ast_rdlock_contexts();
+	if (found)
+		*found = 0;
 	e = pbx_find_extension(c, con, &q, context, exten, priority, label, callerid, action);
 	if (e) {
+		if (found)
+			*found = 1;
 		if (matching_action) {
 			ast_unlock_contexts();
 			return -1;	/* success, we found it */
@@ -1927,19 +1931,19 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
 		ast_unlock_contexts();
 		switch (q.status) {
 		case STATUS_NO_CONTEXT:
-			if (!matching_action)
+			if (!matching_action && !combined_find_spawn)
 				ast_log(LOG_NOTICE, "Cannot find extension context '%s'\n", context);
 			break;
 		case STATUS_NO_EXTENSION:
-			if (!matching_action)
+			if (!matching_action && !combined_find_spawn)
 				ast_log(LOG_NOTICE, "Cannot find extension '%s' in context '%s'\n", exten, context);
 			break;
 		case STATUS_NO_PRIORITY:
-			if (!matching_action)
+			if (!matching_action && !combined_find_spawn)
 				ast_log(LOG_NOTICE, "No such priority %d in extension '%s' in context '%s'\n", priority, exten, context);
 			break;
 		case STATUS_NO_LABEL:
-			if (context)
+			if (context && !combined_find_spawn)
 				ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
 			break;
 		default:
@@ -2376,32 +2380,32 @@ int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_
 
 int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
 {
-	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_MATCH);
+	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_MATCH, 0, 0);
 }
 
 int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
 {
-	return pbx_extension_helper(c, NULL, context, exten, 0, label, callerid, E_FINDLABEL);
+	return pbx_extension_helper(c, NULL, context, exten, 0, label, callerid, E_FINDLABEL, 0, 0);
 }
 
 int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
 {
-	return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL);
+	return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, E_FINDLABEL, 0, 0);
 }
 
 int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
 {
-	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_CANMATCH);
+	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_CANMATCH, 0, 0);
 }
 
 int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
 {
-	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_MATCHMORE);
+	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_MATCHMORE, 0, 0);
 }
 
-int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
+int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn)
 {
-	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_SPAWN);
+	return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, E_SPAWN, found, combined_find_spawn);
 }
 
 /*! helper function to set extension and priority */
@@ -2498,50 +2502,7 @@ static int __ast_pbx_run(struct ast_channel *c)
 		int digit = 0;
 
 		/* loop on priorities in this context/exten */
-		while (ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) {
-			found = 1;
-			if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) {
-				/* Something bad happened, or a hangup has been requested. */
-				if (strchr("0123456789ABCDEF*#", res)) {
-					ast_debug(1, "Oooh, got something to jump out with ('%c')!\n", res);
-					pos = 0;
-					dst_exten[pos++] = digit = res;
-					dst_exten[pos] = '\0';
-					break;
-				}
-				if (res == AST_PBX_KEEPALIVE) {
-					ast_debug(1, "Spawn extension (%s,%s,%d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name);
-					ast_verb(2, "Spawn extension (%s, %s, %d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name);
-					error = 1;
-					break;
-				}
-				ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
-				ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
-
- 				if ((res == AST_PBX_ERROR) && ast_exists_extension(c, c->context, "e", 1, c->cid.cid_num)) {
- 					/* if we are already on the 'e' exten, don't jump to it again */
- 					if (!strcmp(c->exten, "e")) {
- 						if (option_verbose > 1)
- 							ast_verbose(VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", c->context, c->exten, c->priority, c->name);
- 						error = 1;
-						break;
- 					} else {
-						pbx_builtin_raise_exception(c, "ERROR");
- 						continue;
- 					}
- 				}
-
-				if (c->_softhangup == AST_SOFTHANGUP_ASYNCGOTO) {
-					c->_softhangup = 0;
-				} else if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT) {
-					/* atimeout, nothing bad */
-				} else {
-					if (c->cdr)
-						ast_cdr_update(c);
-					error = 1;
-					break;
-				}
-			}
+		while ( !(res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num, &found,1))) {
 			if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT && ast_exists_extension(c, c->context, "T", 1, c->cid.cid_num)) {
 				set_ext_pri(c, "T", 0); /* 0 will become 1 with the c->priority++; at the end */
 				/* If the AbsoluteTimeout is not reset to 0, we'll get an infinite loop */
@@ -2560,6 +2521,45 @@ static int __ast_pbx_run(struct ast_channel *c)
 			}
 			c->priority++;
 		} /* end while  - from here on we can use 'break' to go out */
+		if (found && res) {
+			/* Something bad happened, or a hangup has been requested. */
+			if (strchr("0123456789ABCDEF*#", res)) {
+				ast_debug(1, "Oooh, got something to jump out with ('%c')!\n", res);
+				pos = 0;
+				dst_exten[pos++] = digit = res;
+				dst_exten[pos] = '\0';
+			}
+			if (res == AST_PBX_KEEPALIVE) {
+				ast_debug(1, "Spawn extension (%s,%s,%d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name);
+				ast_verb(2, "Spawn extension (%s, %s, %d) exited KEEPALIVE on '%s'\n", c->context, c->exten, c->priority, c->name);
+				error = 1;
+			}
+			ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
+			ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
+			
+			if ((res == AST_PBX_ERROR) && ast_exists_extension(c, c->context, "e", 1, c->cid.cid_num)) {
+				/* if we are already on the 'e' exten, don't jump to it again */
+				if (!strcmp(c->exten, "e")) {
+					if (option_verbose > 1)
+						ast_verbose(VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", c->context, c->exten, c->priority, c->name);
+					error = 1;
+				} else {
+					pbx_builtin_raise_exception(c, "ERROR");
+					continue;
+				}
+			}
+			
+			if (c->_softhangup == AST_SOFTHANGUP_ASYNCGOTO) {
+				c->_softhangup = 0;
+			} else if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT) {
+				/* atimeout, nothing bad */
+			} else {
+				if (c->cdr)
+					ast_cdr_update(c);
+				error = 1;
+				break;
+			}
+		}
 		if (error)
 			break;
 
@@ -2657,15 +2657,14 @@ static int __ast_pbx_run(struct ast_channel *c)
 		if (c->cdr && ast_opt_end_cdr_before_h_exten)
 			ast_cdr_end(c->cdr);
 		set_ext_pri(c, "h", 1);
-		while (ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) {
-			if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) {
-				/* Something bad happened, or a hangup has been requested. */
-				ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
-				ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
-				break;
-			}
+		while ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num, &found,1))) {
 			c->priority++;
 		}
+		if (found && res) {
+			/* Something bad happened, or a hangup has been requested. */
+			ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
+			ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
+		}
 	}
 	ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
 
@@ -4930,7 +4929,7 @@ int ast_add_extension2(struct ast_context *con,
 	int res;
 	int length;
 	char *p;
-	char expand_buf[VAR_BUF_SIZE] = { 0, };
+	char expand_buf[VAR_BUF_SIZE];
 
 	/* if we are adding a hint, and there are global variables, and the hint
 	   contains variable references, then expand them
@@ -6078,7 +6077,7 @@ int pbx_builtin_importvar(struct ast_channel *chan, void *data)
 	char *name;
 	char *value;
 	char *channel;
-	char tmp[VAR_BUF_SIZE]="";
+	char tmp[VAR_BUF_SIZE];
 	static int deprecation_warning = 0;
 
 	if (ast_strlen_zero(data)) {
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 9b112dc183cc065652a12809813539bf7327c703..0a62da744580ab3d07233d4f193e0ac77711ad1b 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1390,7 +1390,6 @@ static int pbx_load_config(const char *config_file)
 		ast_copy_string(userscontext, "default", sizeof(userscontext));
 								    
 	for (v = ast_variable_browse(cfg, "globals"); v; v = v->next) {
-		memset(realvalue, 0, sizeof(realvalue));
 		pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
 		pbx_builtin_setvar_helper(NULL, v->name, realvalue);
 	}
@@ -1487,20 +1486,17 @@ static int pbx_load_config(const char *config_file)
 					free(tc);
 				}
 			} else if (!strcasecmp(v->name, "include")) {
-				memset(realvalue, 0, sizeof(realvalue));
 				pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
 				if (ast_context_add_include2(con, realvalue, registrar))
 					ast_log(LOG_WARNING, "Unable to include context '%s' in context '%s'\n", v->value, cxt);
 			} else if (!strcasecmp(v->name, "ignorepat")) {
-				memset(realvalue, 0, sizeof(realvalue));
 				pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
 				if (ast_context_add_ignorepat2(con, realvalue, registrar))
 					ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s'\n", v->value, cxt);
 			} else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch") || !strcasecmp(v->name, "eswitch")) {
 				char *stringp = realvalue;
 				char *appl, *data;
-
-				memset(realvalue, 0, sizeof(realvalue));
+				
 				if (!strcasecmp(v->name, "switch"))
 					pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
 				else
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 05d9573633578ef50c2adbdecb1bd486f287e2fb..7f3e0667971edc12284ca247202565fa6e831b89 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -533,7 +533,7 @@ struct dundi_query_state {
 
 static int get_mapping_weight(struct dundi_mapping *map)
 {
-	char buf[32] = "";
+	char buf[32];
 
 	if (map->weightstr) {
 		pbx_substitute_variables_helper(NULL, map->weightstr, buf, sizeof(buf) - 1);
diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c
index dcbef909be9cbc199dfd9f0fd038c48bbcc75d62..3221fb65d0f7dce746ce70911a50ab4239a23878 100644
--- a/pbx/pbx_loopback.c
+++ b/pbx/pbx_loopback.c
@@ -87,7 +87,6 @@ static char *loopback_helper(char *buf, int buflen, const char *exten, const cha
 	char tmp[80];
 
 	snprintf(tmp, sizeof(tmp), "%d", priority);
-	memset(buf, 0, buflen);
 	AST_LIST_HEAD_INIT_NOLOCK(&headp);
 	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("EXTEN", exten), entries);
 	AST_LIST_INSERT_HEAD(&headp, ast_var_assign("CONTEXT", context), entries);
@@ -141,8 +140,9 @@ static int loopback_canmatch(struct ast_channel *chan, const char *context, cons
 
 static int loopback_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
 {
+	int found;
 	LOOPBACK_COMMON;
-	res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid);
+	res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid, &found, 0);
 	/* XXX hmmm... res is overridden ? */
 	if (newpattern && !ast_extension_match(newpattern, exten))
 		res = -1;
diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c
index 31d266d0e972e6f0953fb7d417623de455e47eca..d733dc052b0d97b45b9753ff135b766cd850e08e 100644
--- a/pbx/pbx_realtime.c
+++ b/pbx/pbx_realtime.c
@@ -191,7 +191,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
 		if (!ast_strlen_zero(app)) {
 			struct ast_app *a = pbx_findapp(app);
 			if (a) {
-				char appdata[512]="";
+				char appdata[512];
 				char tmp1[80];
 				char tmp2[80];
 				char tmp3[EXT_DATA_SIZE];
diff --git a/res/ael/pval.c b/res/ael/pval.c
index 4c26d1aa1e83b62a109bc048e9021ff115ff6100..5deb01828490752b9f9e4ae38528b85a19a688da 100644
--- a/res/ael/pval.c
+++ b/res/ael/pval.c
@@ -3788,7 +3788,6 @@ void add_extensions(struct ael_extension *exten)
 	do {
 		struct ael_priority *last = 0;
 		
-		memset(realext, '\0', sizeof(realext)); /* make sure this is properly initialized */
 		pbx_substitute_variables_helper(NULL, exten->name, realext, sizeof(realext) - 1);
 		if (exten->hints) {
 			if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, PRIORITY_HINT, NULL, exten->cidmatch, 
diff --git a/res/res_agi.c b/res/res_agi.c
index 8f722f082c8b9fb1f018630bfba95c94aed0fbdb..80dd168a307ef0f45cedb0dbd8f574a2ce49ebb7 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -1192,7 +1192,7 @@ static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, char
 
 static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc, char **argv)
 {
-	char tmp[4096] = "";
+	char tmp[4096];
 	struct ast_channel *chan2=NULL;
 
 	if ((argc != 4) && (argc != 5))
diff --git a/utils/extconf.c b/utils/extconf.c
index 0d30cc9f95b530eb49cd6c44a51d1e265dfeda55..fa31102eb320dc7a217001cf38f6db2999a78b83 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -5700,6 +5700,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 	char *vars, *vare;
 	int pos, brackets, needsub, len;
 
+	*cp2 = 0; /* just in case there's nothing to do */
 	whereweare=tmp=cp1;
 	while (!ast_strlen_zero(whereweare) && count) {
 		/* Assume we're copying the whole remaining string */
@@ -5731,6 +5732,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 			count -= pos;
 			cp2 += pos;
 			whereweare += pos;
+			*cp2 = 0;
 		}
 
 		if (nextvar) {
@@ -5802,6 +5804,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 				memcpy(cp2, cp4, length);
 				count -= length;
 				cp2 += length;
+				*cp2 = 0;
 			}
 		} else if (nextexp) {
 			/* We have an expression.  Find the start and end, and determine
@@ -5859,6 +5862,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
 					ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
 				count -= length;
 				cp2 += length;
+				*cp2 = 0;
 			}
 		} else
 			break;