diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c
index d7d95c6009ccff04a682cc5e96f059a7a6ea7ce5..8bd2b4beb27e98b58448a2be8cf7c17a693e5e56 100644
--- a/src/lib-sieve/sieve-actions.c
+++ b/src/lib-sieve/sieve-actions.c
@@ -150,9 +150,13 @@ static void act_store_print
 	const struct sieve_result_print_env *rpenv, void *context, bool *keep)	
 {
 	struct act_store_context *ctx = (struct act_store_context *) context;
-	
+	const char *folder;
+
+	folder = ( ctx == NULL ? 
+		SIEVE_SCRIPT_DEFAULT_MAILBOX(rpenv->scriptenv) : ctx->folder );	
+
 	sieve_result_action_printf(rpenv, "store message in folder: %s", 
-		str_sanitize(ctx->folder, 128));
+		str_sanitize(folder, 128));
 	
 	*keep = FALSE;
 }
diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c
index 4a95352269d79d031ff9144739f9f9e99c61cb57..0ed5e1d43e8bd881e537791491e4c6f633465b04 100644
--- a/src/lib-sieve/sieve-result.c
+++ b/src/lib-sieve/sieve-result.c
@@ -383,10 +383,15 @@ static int _sieve_result_add_action
 						if ( (ret=sieve_result_side_effects_merge
 							(renv, action, raction->seffects, seffects)) < 0 ) 
 							return ret;
+							
 						raction->keep = TRUE;
 						raction->data.context = NULL;
 						raction->data.location = p_strdup(result->pool, act_data.location);
 						
+						/* Note that existing execution status is retained, making sure that
+						 * keep is not executed multiple times.
+						 */
+						
 						return 1;
 					} else {
 						/* Merge side-effects, but don't add new action */
@@ -566,7 +571,8 @@ void sieve_result_seffect_printf
 }
 
 bool sieve_result_print
-(struct sieve_result *result, struct ostream *stream)
+(struct sieve_result *result, const struct sieve_script_env *senv, 
+	struct ostream *stream)
 {
 	struct sieve_result_print_env penv;
 	bool implicit_keep = TRUE;
@@ -574,6 +580,7 @@ bool sieve_result_print
 	
 	penv.result = result;
 	penv.stream = stream;
+	penv.scriptenv = senv;
 	
 	sieve_result_printf(&penv, "\nPerformed actions:\n\n");
 	rac = result->first_action;
@@ -581,17 +588,20 @@ bool sieve_result_print
 		bool keep = TRUE;
 		struct sieve_result_side_effect *rsef;
 		const struct sieve_side_effect *sef;
+		const struct sieve_action *act = rac->data.action;
 
-		if ( !rac->keep ) {
-			const struct sieve_action *act = rac->data.action;
-
+		if ( act != NULL ) {
 			if ( act->print != NULL )
 				act->print(act, &penv, rac->data.context, &keep);
 			else
 				sieve_result_action_printf(&penv, act->name); 
 		} else {
-			sieve_result_action_printf(&penv, "keep");
-			keep = FALSE; 
+			if ( rac->keep ) {
+				sieve_result_action_printf(&penv, "keep");
+				keep = FALSE;
+			} else {
+				sieve_result_action_printf(&penv, "[NULL]");
+			}
 		}
 	
 		/* Print side effects */
diff --git a/src/lib-sieve/sieve-result.h b/src/lib-sieve/sieve-result.h
index 18a1b65e67246d695a5eee6bdc2dac1b6c5e836e..30a78b6a27c80c15fe95f64b953840ad940e94fb 100644
--- a/src/lib-sieve/sieve-result.h
+++ b/src/lib-sieve/sieve-result.h
@@ -46,6 +46,7 @@ const void *sieve_result_extension_get_context
 
 struct sieve_result_print_env {
 	struct sieve_result *result;
+	const struct sieve_script_env *scriptenv;
 	struct ostream *stream;
 };
 
@@ -56,7 +57,9 @@ void sieve_result_action_printf
 void sieve_result_seffect_printf
 	(const struct sieve_result_print_env *penv, const char *fmt, ...);
 
-bool sieve_result_print(struct sieve_result *result, struct ostream *stream);
+bool sieve_result_print
+	(struct sieve_result *result, const struct sieve_script_env *senv, 
+		struct ostream *stream);
 
 /* 
  * Error handling 
diff --git a/src/lib-sieve/sieve.c b/src/lib-sieve/sieve.c
index 2ae1c00de8547a06139e4a94d9effa4832a33edd..6f6b6465e92776b554b6188a3d16d7292cccd399 100644
--- a/src/lib-sieve/sieve.c
+++ b/src/lib-sieve/sieve.c
@@ -261,7 +261,7 @@ int sieve_test
 	ret = sieve_interpreter_run(interp, msgdata, senv, &sres, estatus);
 	
 	if ( ret > 0 ) 
-		ret = sieve_result_print(sres, stream);
+		ret = sieve_result_print(sres, senv, stream);
 	
 	sieve_interpreter_free(&interp);
 	sieve_result_unref(&sres);
diff --git a/src/testsuite/testsuite-result.c b/src/testsuite/testsuite-result.c
index 5fb8a433d92a3c91bcb6d8bcdd06676436c8fa28..16e5d4ffc62380e4201e44cd2103da11880fca7c 100644
--- a/src/testsuite/testsuite-result.c
+++ b/src/testsuite/testsuite-result.c
@@ -84,13 +84,15 @@ bool testsuite_result_execute(const struct sieve_runtime_env *renv)
 }
 
 void testsuite_result_print
-(const struct sieve_runtime_env *renv ATTR_UNUSED)
+(const struct sieve_runtime_env *renv)
 {
 	struct ostream *out;
 	
 	out = o_stream_create_fd(1, 0, FALSE);	
 
-	sieve_result_print(_testsuite_result, out);
+	o_stream_send_str(out, "\n--");
+	sieve_result_print(_testsuite_result, renv->scriptenv, out);
+	o_stream_send_str(out, "--\n\n");
 
 	o_stream_destroy(&out);	
 }
diff --git a/tests/multiscript/conflicts.svtest b/tests/multiscript/conflicts.svtest
index be9a58edc881efc0cd9418da7c61dae879be5fe4..7af89f4a84f6274e983dfee2fff15eea54df47d2 100644
--- a/tests/multiscript/conflicts.svtest
+++ b/tests/multiscript/conflicts.svtest
@@ -49,3 +49,46 @@ test "Graceful Conflicts" {
 		test_fail "reject action not discarded";
 	}
 }
+
+test "Duplicates" {
+	if not allof (
+		test_script_compile "fileinto-inbox.sieve",
+		test_script_run ){
+		test_fail "failed to compile and run first script";
+	}
+
+	if not test_result_execute {
+		test_fail "result execute failed after first script";
+	}
+
+	if not allof ( 
+		test_script_compile "fileinto-inbox.sieve",
+		test_script_run :append_result ) {
+		test_fail "failed to compile and run second script";
+	}
+
+	if not test_result_execute {
+		test_fail "result execute failed after second script";
+	}
+
+	if not allof ( 
+		test_script_compile "keep.sieve",
+		test_script_run :append_result ) {
+		test_fail "failed to compile and run third script";
+	}
+
+	if not test_result_execute {
+		test_fail "result execute failed after third script";
+	}
+
+	test_result_print;
+
+	if not test_result :index 1 "keep" {
+		test_fail "first action is not 'keep'";
+	}
+
+	if test_result :index 2 "store" {
+		test_fail "fileinto action not discarded";
+	}
+}
+
diff --git a/tests/multiscript/fileinto-frop.sieve b/tests/multiscript/fileinto-frop.sieve
new file mode 100644
index 0000000000000000000000000000000000000000..9aafb95034f1d70d0c68be6fcd12d23da3f56be1
--- /dev/null
+++ b/tests/multiscript/fileinto-frop.sieve
@@ -0,0 +1,3 @@
+require "fileinto";
+
+fileinto "frop";
diff --git a/tests/multiscript/keep.sieve b/tests/multiscript/keep.sieve
new file mode 100644
index 0000000000000000000000000000000000000000..6203a214af1cedabcf368d8c0451a554027ad2cb
--- /dev/null
+++ b/tests/multiscript/keep.sieve
@@ -0,0 +1 @@
+keep;