diff --git a/.hgsigs b/.hgsigs
index fc045f5264891d8b7586ebbf3d922b2033ccebd0..d6a636c2229a2ddaa87da611d2d858db5356879d 100644
--- a/.hgsigs
+++ b/.hgsigs
@@ -5,3 +5,5 @@ df8b38da248cbd6d83e9bd476ec2c92716ea193c 0 iQEcBAABAgAGBQJM/WxCAAoJEATWKx49+7T0b
 873baa85e2202f45a9c14fa21cccedc60f3715bc 0 iQEcBAABAgAGBQJOx9MCAAoJEATWKx49+7T09aUIANIKsuzM3bGhtGJ/UPIwzpOu39lEGCmHah6dMa+bDOoCZhuhASDdTuvRKXTfGC57GMu+NzBK6I7heFiPD3E4VTI4xOCK1azJ9G4SsiDEkQThucXqWBKDjPB0RgOEf6iefAkslXIU3cprJgattwpeXbUKiHjBhoYJFJ5j/GTx1B62ndvaTfMu1zF5UppiyRG1rQD7FLY4f6kANzSI2jOOCBs4UFH7ZKhafO1AeQfLNDvxdDczZafPZxrCIF+5JCNvQ6Xue/JrvRZQ0V9sxLQat7clUJ6I6Ejl5u5l1LF+VscWldfaQKwDdOktCVux84YGH8+XqXaukMiEg6j4hceAYIM=
 fe7bd7ee6c2e33e38515cbeca7642135db8dea4b 0 iQEcBAABAgAGBQJPPXAPAAoJEATWKx49+7T0iqMH/3e+RKKmryOz5pak0cvdPcS/D9O9xl2l6SuoE2okTq/WOrDtZ1xDg0afg7t27D9mDfUY1hiSFS4ekN3WP620Gcb9wlL3FC+rLEYmiE8iSfZvsH+FeLa7n8NB+XdnAsXE1WdLQp5CSKEh3sXIod7Q04PL0uv/rimGS9jOGcAufW3y9QAYd+DVorPS4lV5Kz8qIqY9r/0lLqhJN1ukIJtClVkFanRljd+SfoHFFOSWbQjCKNxlOSWFhwJji7Mp091A1+N6JoZe4IMIlajMsM2Ypp726Y2LA/du+uRVFjKgta65eP9tfdrmVCJtrjIjvikowD5Zl80GuVRI5j44aQ7rJ3A=
 e9ed5d5cef4b3b27ac5d980b3e4aeadaabeeeae2 0 iQEcBAABAgAGBQJPwA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6u1LlbGaojtJA03V1L+a8QkmltiurD9VNmiHz++bGGJlA7LSmVYBq7BeC1lDnXUGO9ryZgln6aXRwUS0VaTI51F9gSMw+0UDJCwA5yBKqYyR8=
diff --git a/NEWS b/NEWS
index 257014818abe0aa0e9f40e68ffda7ca2f1b8faef..e07b758bbff04d5d48ef84f2d763eebc54d94340 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,26 @@
+v0.3.3 18-09-2012 Stephan Bosch <stephan@rename-it.nl>
+
+	- Fixed compile against installed Dovecot headers. This was broken by the
+	  ld.gold fix in the previous release.
+
+v0.3.2 18-09-2012 Stephan Bosch <stephan@rename-it.nl>
+
+	+ sieve-refilter tool: improved man page documentation by explicitly
+	  specifying the syntax used for mailbox arguments.
+	+ Sieve: spamtest and virustest extensions: improved trace debugging of score
+	  calculation.
+	+ Sieve: made error messages about exceeding the maximum number of actions
+	  more verbose.
+	- Sieve tools: fixed problems with running as root: sievec and sieve-dump now
+	  ignore mail_uid and mail_gid settings when run as root.
+	- Sieve: fixed bug in action accounting (for limit checking): increase action
+	  instance count only when an action is actually created.
+	- Sieve: include extension: fixed namespace separation of :global and
+	  :personal scripts.
+	- ManageSieve: fixed segfault bug triggered by CHECKSCRIPT command.
+	- Fixed linking with ld.gold.
+	- Fixed several Clang compile warnings and a few potential bugs.
+
 v0.3.1 25-05-2012 Stephan Bosch <stephan@rename-it.nl>
 
 	* Added support for retrieving Sieve scripts from dict lookup. This means that
diff --git a/doc/man/sieve-filter.1.in b/doc/man/sieve-filter.1.in
index 9f74e3854eeaab859d4492f01a36c28b62707746..1566dfa6db52f0501c0bfbc92d5085358c8bb935 100644
--- a/doc/man/sieve-filter.1.in
+++ b/doc/man/sieve-filter.1.in
@@ -92,7 +92,8 @@ The mailbox where the (implicit) \fBkeep\fP Sieve action stores messages. This
 is equal to the \fIsource\-mailbox\fP by default. Specifying a different folder
 will have the effect of moving (or copying if \fB\-W\fP is omitted) all kept
 messages to the indicated folder, instead of just leaving them in the
-\fIsource\-mailbox\fP.
+\fIsource\-mailbox\fP. Refer to the explanation of the \fIsource\-mailbox\fP
+argument for more information on mailbox naming.
 .TP
 .BI \-q\  output\-mailbox\  \fB[not\ implemented\ yet]\fP
 Store outgoing e\-mail into the indicated \fIoutput\-mailbox\fP. By default,
@@ -153,9 +154,18 @@ extension and with basename and path identical to the specified script. Use the
 into a new binary.
 .TP
 .I source\-mailbox
-The name of the source mailbox containing the messages that the Sieve filter
-will act upon. This mailbox is not modified unless the \fB\-W\fP option is
-specified.
+Specifies the source mailbox containing the messages that the Sieve filter will
+act upon.
+
+This is the name of a mailbox, as visible to IMAP clients, except in UTF-8
+format. The hierarchy separator between a parent and child mailbox is commonly
+.RB \(aq / \(aq
+or
+.RB \(aq . \(aq,
+but this depends on your selected mailbox storage format and
+namespace configuration. The mailbox names may also require a namespace prefix.
+
+This mailbox is not modified unless the \fB\-W\fP option is specified.
 .TP
 .I discard\-action
 Specifies what is done with messages in the \fIsource\-mailbox\fP that where not
@@ -169,7 +179,8 @@ Keep discarded messages in source mailbox.
 .TP
 .BI move\  mailbox
 Move discarded messages to the indicated \fImailbox\fP. This is for instance
-useful to move messages to a Trash mailbox.
+useful to move messages to a Trash mailbox. Refer to the explanation of
+the \fIsource\-mailbox\fP argument for more information on mailbox naming.
 .TP
 .B delete
 Flag discarded messages as \\DELETED.
diff --git a/src/lib-sieve-tool/sieve-tool.c b/src/lib-sieve-tool/sieve-tool.c
index d3a055878a7a8519f0c42d6f34efca31ed71a0e9..2a892506f14ccb7c2d872fd0e17096bcb52796ef 100644
--- a/src/lib-sieve-tool/sieve-tool.c
+++ b/src/lib-sieve-tool/sieve-tool.c
@@ -112,14 +112,14 @@ static void sieve_tool_get_user_data
 		home == NULL || *home == '\0' ) {
 
 		if ((pw = getpwuid(process_euid)) != NULL) {
-            user = pw->pw_name;
+			user = pw->pw_name;
 			home = pw->pw_dir;
 		}
 	}
 
 	if ( username_r != NULL ) {
 		if ( user == NULL || *user == '\0' ) {
-            i_fatal("couldn't lookup our username (uid=%s)",
+			i_fatal("couldn't lookup our username (uid=%s)",
 				dec2str(process_euid));
 		}
 
@@ -216,7 +216,7 @@ static void sieve_tool_load_plugins
 }
 
 struct sieve_instance *sieve_tool_init_finish
-(struct sieve_tool *tool, bool init_mailstore)
+(struct sieve_tool *tool, bool init_mailstore, bool preserve_root)
 {
 	enum mail_storage_service_flags storage_service_flags =
 		MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR |
@@ -238,9 +238,15 @@ struct sieve_instance *sieve_tool_init_finish
 		if ( tool->homedir != NULL )
 			i_free(tool->homedir);
 		tool->homedir = i_strdup(homedir);
-	} else
+
+		if ( preserve_root ) {
+			storage_service_flags |=
+				MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS;
+		}
+	} else {
 		storage_service_flags |=
 			MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
+	}
 
 	if ( !init_mailstore )
 		storage_service_flags |=
diff --git a/src/lib-sieve-tool/sieve-tool.h b/src/lib-sieve-tool/sieve-tool.h
index 254d14ff1f77fbfbf69f55797385b7b12bedd2d9..b24bb47ec06b98487942c822a4ae9f09bac57262 100644
--- a/src/lib-sieve-tool/sieve-tool.h
+++ b/src/lib-sieve-tool/sieve-tool.h
@@ -30,7 +30,7 @@ struct sieve_tool *sieve_tool_init
 int sieve_tool_getopt(struct sieve_tool *tool);
 
 struct sieve_instance *sieve_tool_init_finish
-	(struct sieve_tool *tool, bool init_mailstore);
+	(struct sieve_tool *tool, bool init_mailstore, bool preserve_root);
 
 void sieve_tool_deinit(struct sieve_tool **_tool);
 
diff --git a/src/lib-sieve/plugins/include/ext-include-binary.c b/src/lib-sieve/plugins/include/ext-include-binary.c
index 6f9678733d0850974aacbeee95ad93f48ba00f03..5e01f4fe0fef17be5020701dd99ac656f1f71443 100644
--- a/src/lib-sieve/plugins/include/ext-include-binary.c
+++ b/src/lib-sieve/plugins/include/ext-include-binary.c
@@ -302,7 +302,6 @@ static bool ext_include_binary_open
 				"include: failed to find block %d for included script "
 				"from dependency block %d of binary %s", inc_block_id, block_id,
 				sieve_binary_path(sbin));
-
 			return FALSE;
 		}
 
diff --git a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c
index bc440c1d7462c2637c632b9318cc475d8dccf481..22eb4e03daae4bca6f82e4446a957c7617ac7d5a 100644
--- a/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c
+++ b/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c
@@ -156,7 +156,7 @@ static bool seff_mailbox_create_pre_execute
 	}
 
 	/* Try opening again */
-	if ( mailbox_sync(trans->box, 0) < 0 ) {
+	if ( mailbox_open(trans->box) < 0 ) {
 		/* Failed definitively */
 		sieve_act_store_get_storage_error(aenv, trans);
 		return FALSE;
diff --git a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
index 628941658de0bd9fe68380e96a2bd4dcf59bc767..a93cdc0a28de02f5b0db69291c45e8ef1d767c0a 100644
--- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
+++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
@@ -457,7 +457,6 @@ const char *ext_spamvirustest_get_value
 	const struct sieve_message_data *msgdata = renv->msgdata;
 	struct sieve_message_context *msgctx = renv->msgctx;
 	struct ext_spamvirustest_message_context *mctx;
-	const char *ext_name = sieve_extension_name(ext);
 	regmatch_t match_values[2];
 	const char *header_value, *error;
 	const char *status = NULL, *max = NULL;
@@ -470,7 +469,7 @@ const char *ext_spamvirustest_get_value
 	 */
 	if ( ext_data == NULL ) {
 		sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-			"%s: extension not configured", ext_name);
+			"error: extension not configured");
 		return "0";
 	}
 
@@ -504,8 +503,8 @@ const char *ext_spamvirustest_get_value
 				(msgdata->mail, max_header->header_name, &header_value) < 0 ||
 				header_value == NULL ) {
 				sieve_runtime_trace(renv,  SIEVE_TRLVL_TESTS,
-					"%s: header '%s' not found in message",
-					ext_name, max_header->header_name);
+					"header '%s' not found in message",
+					max_header->header_name);
 				goto failed;
 			}
 
@@ -514,16 +513,16 @@ const char *ext_spamvirustest_get_value
 				if ( regexec(&max_header->regexp, header_value, 2, match_values, 0)
 					!= 0 ) {
 					sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-						"%s: regexp for header '%s' did not match "
-						"on value '%s'", ext_name, max_header->header_name, header_value);
+						"regexp for header '%s' did not match "
+						"on value '%s'", max_header->header_name, header_value);
 					goto failed;
 				}
 
 				max = _regexp_match_get_value(header_value, 1, match_values, 2);
 				if ( max == NULL ) {
 					sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-						"%s: regexp did not return match value "
-						"for string '%s'", ext_name, header_value);
+						"regexp did not return match value "
+						"for string '%s'", header_value);
 					goto failed;
 				}
 			} else {
@@ -532,7 +531,7 @@ const char *ext_spamvirustest_get_value
 
 			if ( !ext_spamvirustest_parse_decimal_value(max, &max_value, &error) ) {
 				sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-					"%s: failed to parse maximum value: %s", ext_name, error);
+					"failed to parse maximum value: %s", error);
 				goto failed;
 			}
 		} else {
@@ -541,7 +540,7 @@ const char *ext_spamvirustest_get_value
 
 		if ( max_value == 0 ) {
 			sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-				"%s: max value is 0", ext_name);
+				"error: max value is 0");
 			goto failed;
 		}
 	} else {
@@ -557,8 +556,8 @@ const char *ext_spamvirustest_get_value
 		(msgdata->mail, status_header->header_name, &header_value) < 0 ||
 		header_value == NULL ) {
 		sieve_runtime_trace(renv,  SIEVE_TRLVL_TESTS,
-			"%s: header '%s' not found in message",
-			ext_name, status_header->header_name);
+			"header '%s' not found in message",
+			status_header->header_name);
 		goto failed;
 	}
 
@@ -567,16 +566,16 @@ const char *ext_spamvirustest_get_value
 		if ( regexec(&status_header->regexp, header_value, 2, match_values, 0)
 			!= 0 ) {
 			sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-				"%s: regexp for header '%s' did not match on value '%s'",
-			ext_name, status_header->header_name, header_value);
+				"regexp for header '%s' did not match on value '%s'",
+				status_header->header_name, header_value);
 			goto failed;
 		}
 
 		status = _regexp_match_get_value(header_value, 1, match_values, 2);
 		if ( status == NULL ) {
 			sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-				"%s: regexp did not return match value for string '%s'",
-				ext_name, header_value);
+				"regexp did not return match value for string '%s'",
+				header_value);
 			goto failed;
 		}
 	} else {
@@ -588,8 +587,8 @@ const char *ext_spamvirustest_get_value
 		if ( !ext_spamvirustest_parse_decimal_value
 			(status, &status_value, &error) ) {
 			sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-				"%s: failed to parse status value '%s': %s",
-				ext_name, status, error);
+				"failed to parse status value '%s': %s",
+				status, error);
 			goto failed;
 		}
 		break;
@@ -597,8 +596,8 @@ const char *ext_spamvirustest_get_value
 		if ( !ext_spamvirustest_parse_strlen_value
 			(status, &status_value, &error) ) {
 			sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-				"%s: failed to parse status value '%s': %s",
-				ext_name, status, error);
+				"failed to parse status value '%s': %s",
+				status, error);
 			goto failed;
 		}
 		break;
@@ -618,8 +617,8 @@ const char *ext_spamvirustest_get_value
 
 		if ( i > max_text ) {
 			sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
-				"%s: failed to match textstatus value '%s'",
-				ext_name, status);
+				"failed to match textstatus value '%s'",
+				status);
 			goto failed;
 		}
 		break;
@@ -636,6 +635,10 @@ const char *ext_spamvirustest_get_value
 	else
 		mctx->score_ratio = (status_value / max_value);
 
+	sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS,
+		"extracted score=%.3f, max=%.3f, ratio=%.0f %%",
+		status_value, max_value, mctx->score_ratio * 100);
+
 	return ext_spamvirustest_get_score(ext, mctx->score_ratio, percent);
 
 failed:
diff --git a/src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c b/src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c
index 0a2a0f383ee246055d3f5009be8484770f265d97..67b9e1fc29e33961d843c26ca9d6c3a0f0506931 100644
--- a/src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c
+++ b/src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c
@@ -290,7 +290,9 @@ static int tst_spamvirustest_operation_execute
 	}
 
 	/* Get score value */
+	sieve_runtime_trace_descend(renv);
 	score_value = ext_spamvirustest_get_value(renv, this_ext, percent);
+	sieve_runtime_trace_ascend(renv);
 
 	/* Construct value list */
 	value_list = sieve_single_stringlist_create_cstr(renv, score_value, TRUE);
diff --git a/src/sieve-tools/sieve-dump.c b/src/sieve-tools/sieve-dump.c
index 7e8d28ce22d0f7cd5fc53872c33e123f425eb363..20cc31aa41b505d600363719938fa46df9b77200 100644
--- a/src/sieve-tools/sieve-dump.c
+++ b/src/sieve-tools/sieve-dump.c
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
 	}
 
 	/* Finish tool initialization */
-	svinst = sieve_tool_init_finish(sieve_tool, FALSE);
+	svinst = sieve_tool_init_finish(sieve_tool, FALSE, TRUE);
 
         /* Enable debug extension */
         sieve_enable_debug_extension(svinst);
diff --git a/src/sieve-tools/sieve-filter.c b/src/sieve-tools/sieve-filter.c
index 1381266b263e1332c1d2d52264410975edf910ac..279cb923ce9f25f37bec795477426daa9dc08286 100644
--- a/src/sieve-tools/sieve-filter.c
+++ b/src/sieve-tools/sieve-filter.c
@@ -473,7 +473,7 @@ int main(int argc, char **argv)
 	}
 
 	/* Finish tool initialization */
-	svinst = sieve_tool_init_finish(sieve_tool, TRUE);
+	svinst = sieve_tool_init_finish(sieve_tool, TRUE, FALSE);
 
 	/* Enable debug extension */
 	sieve_enable_debug_extension(svinst);
diff --git a/src/sieve-tools/sieve-test.c b/src/sieve-tools/sieve-test.c
index 11ace2731869856e80d0544ed4f0ebfee04d0aa8..b1ffe7b1cdb0ed09838d50e7887c5bb49edd8b7d 100644
--- a/src/sieve-tools/sieve-test.c
+++ b/src/sieve-tools/sieve-test.c
@@ -210,7 +210,7 @@ int main(int argc, char **argv)
 	}
 
 	/* Finish tool initialization */
-	svinst = sieve_tool_init_finish(sieve_tool, execute && mailloc == NULL);
+	svinst = sieve_tool_init_finish(sieve_tool, execute && mailloc == NULL, FALSE);
 
 	/* Enable debug extension */
 	sieve_enable_debug_extension(svinst);
diff --git a/src/sieve-tools/sievec.c b/src/sieve-tools/sievec.c
index df60dd1413babebb07e92e5eeb83d2742fa092ac..7055dfcaad7d7cb2d9a9b0f2c47007ca94dd1a9e 100644
--- a/src/sieve-tools/sievec.c
+++ b/src/sieve-tools/sievec.c
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
 		outfile = "-";
 	}
 
-	svinst = sieve_tool_init_finish(sieve_tool, FALSE);
+	svinst = sieve_tool_init_finish(sieve_tool, FALSE, TRUE);
 
 	/* Enable debug extension */
 	sieve_enable_debug_extension(svinst);
diff --git a/src/testsuite/testsuite.c b/src/testsuite/testsuite.c
index dd9be67bf27caef0f3778718b569e1bc36e731af..73d4a68d15c72910050ac0c2c8467f01334b8c35 100644
--- a/src/testsuite/testsuite.c
+++ b/src/testsuite/testsuite.c
@@ -154,7 +154,7 @@ int main(int argc, char **argv)
 		("sieve_global_dir", t_strconcat(sieve_dir, "included-global", NULL));
 
 	/* Finish testsuite initialization */
-	svinst = sieve_tool_init_finish(sieve_tool, FALSE);
+	svinst = sieve_tool_init_finish(sieve_tool, FALSE, FALSE);
 	testsuite_init(svinst, sieve_dir, log_stdout);
 
 	printf("Test case: %s:\n\n", scriptfile);