diff --git a/res/res_monitor.c b/res/res_monitor.c
index bda1ccfbfd6d024feddfc5c963f99bcbb1139c5f..959a80c3ff766fa26bcec889ff73ea2acd078cd9 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -306,13 +306,14 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha
 		if (!ast_strlen_zero(fname_base)) {
 			int directory = strchr(fname_base, '/') ? 1 : 0;
 			const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
+			const char *absolute_suffix = *fname_base == '/' ? "" : "/";
 
-			snprintf(monitor->read_filename, FILENAME_MAX, "%s/%s-in",
-						absolute, fname_base);
-			snprintf(monitor->write_filename, FILENAME_MAX, "%s/%s-out",
-						absolute, fname_base);
-			snprintf(monitor->filename_base, FILENAME_MAX, "%s/%s",
-					 	absolute, fname_base);
+			snprintf(monitor->read_filename, FILENAME_MAX, "%s%s%s-in",
+						absolute, absolute_suffix, fname_base);
+			snprintf(monitor->write_filename, FILENAME_MAX, "%s%s%s-out",
+						absolute, absolute_suffix, fname_base);
+			snprintf(monitor->filename_base, FILENAME_MAX, "%s%s%s",
+					 	absolute, absolute_suffix, fname_base);
 
 			/* try creating the directory just in case it doesn't exist */
 			if (directory) {
@@ -467,11 +468,9 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l
 			char tmp[1024];
 			char tmp2[1024];
 			const char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
-			char *name = chan->monitor->filename_base;
-			int directory = strchr(name, '/') ? 1 : 0;
-			const char *dir = directory ? "" : ast_config_AST_MONITOR_DIR;
+			char *fname_base = chan->monitor->filename_base;
 			const char *execute, *execute_args;
-			const char *absolute = *name == '/' ? "" : "/";
+			/* at this point, fname_base really is the full path */
 
 			/* Set the execute application */
 			execute = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC");
@@ -489,9 +488,10 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l
 				execute_args = "";
 			}
 			
-			snprintf(tmp, sizeof(tmp), "%s \"%s%s%s-in.%s\" \"%s%s%s-out.%s\" \"%s%s%s.%s\" %s &", execute, dir, absolute, name, format, dir, absolute, name, format, dir, absolute, name, format,execute_args);
+			snprintf(tmp, sizeof(tmp), "%s \"%s-in.%s\" \"%s-out.%s\" \"%s.%s\" %s &",
+				execute, fname_base, format, fname_base, format, fname_base, format,execute_args);
 			if (delfiles) {
-				snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s%s%s-\"* ) &",tmp, dir, absolute, name); /* remove legs when done mixing */
+				snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s-\"* ) &",tmp, fname_base); /* remove legs when done mixing */
 				ast_copy_string(tmp, tmp2, sizeof(tmp));
 			}
 			ast_debug(1,"monitor executing %s\n",tmp);
@@ -561,11 +561,18 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co
 	if (chan->monitor) {
 		int directory = strchr(fname_base, '/') ? 1 : 0;
 		const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
+		const char *absolute_suffix = *fname_base == '/' ? "" : "/";
 		char tmpstring[sizeof(chan->monitor->filename_base)] = "";
 		int i, fd[2] = { -1, -1 }, doexit = 0;
 
 		/* before continuing, see if we're trying to rename the file to itself... */
-		snprintf(tmpstring, sizeof(tmpstring), "%s/%s", absolute, fname_base);
+		snprintf(tmpstring, sizeof(tmpstring), "%s%s%s", absolute, absolute_suffix, fname_base);
+
+		/* try creating the directory just in case it doesn't exist */
+		if (directory) {
+			char *name = ast_strdupa(tmpstring);
+			ast_mkdir(dirname(name), 0777);
+		}
 
 		/*!\note We cannot just compare filenames, due to symlinks, relative
 		 * paths, and other possible filesystem issues.  We could use
@@ -597,6 +604,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co
 			}
 		}
 		unlink(tmpstring);
+		/* if previous monitor file existed in a subdirectory, the directory will not be removed */
 		unlink(chan->monitor->filename_base);
 
 		if (doexit) {
@@ -604,12 +612,6 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co
 			return 0;
 		}
 
-		/* try creating the directory just in case it doesn't exist */
-		if (directory) {
-			char *name = ast_strdupa(fname_base);
-			ast_mkdir(dirname(name), 0777);
-		}
-
 		ast_copy_string(chan->monitor->filename_base, tmpstring, sizeof(chan->monitor->filename_base));
 		chan->monitor->filename_changed = 1;
 	} else {