diff --git a/src/lib-sieve/plugins/duplicate/ext-duplicate-common.c b/src/lib-sieve/plugins/duplicate/ext-duplicate-common.c
index 48e244b71000417d81eaa14c0b5fba6666677ef6..41262233b5a4502e146fc0a1ca29b3c695d0670d 100644
--- a/src/lib-sieve/plugins/duplicate/ext-duplicate-common.c
+++ b/src/lib-sieve/plugins/duplicate/ext-duplicate-common.c
@@ -28,17 +28,12 @@
 #define EXT_DUPLICATE_DEFAULT_PERIOD (12*60*60)
 #define EXT_DUPLICATE_DEFAULT_MAX_PERIOD (2*24*60*60)
 
-int ext_duplicate_load(const struct sieve_extension *ext, void **context)
+int ext_duplicate_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	struct ext_duplicate_context *extctx;
 	sieve_number_t default_period, max_period;
 
-	if (*context != NULL) {
-		ext_duplicate_unload(ext);
-		*context = NULL;
-	}
-
 	if (!sieve_setting_get_duration_value(
 		svinst, "sieve_duplicate_default_period", &default_period))
 		default_period = EXT_DUPLICATE_DEFAULT_PERIOD;
@@ -51,7 +46,7 @@ int ext_duplicate_load(const struct sieve_extension *ext, void **context)
 	extctx->default_period = default_period;
 	extctx->max_period = max_period;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/duplicate/ext-duplicate-common.h b/src/lib-sieve/plugins/duplicate/ext-duplicate-common.h
index a5181f2c89548629eafbc46e56ebc3903709d258..3ad0b790754fd007f592927ae51a199d495c92f8 100644
--- a/src/lib-sieve/plugins/duplicate/ext-duplicate-common.h
+++ b/src/lib-sieve/plugins/duplicate/ext-duplicate-common.h
@@ -12,7 +12,7 @@ struct ext_duplicate_context {
 	unsigned int max_period;
 };
 
-int ext_duplicate_load(const struct sieve_extension *ext, void **context);
+int ext_duplicate_load(const struct sieve_extension *ext, void **context_r);
 void ext_duplicate_unload(const struct sieve_extension *ext);
 
 extern const struct sieve_extension_def duplicate_extension;
diff --git a/src/lib-sieve/plugins/editheader/ext-editheader-common.c b/src/lib-sieve/plugins/editheader/ext-editheader-common.c
index a28d25d190922f39fab98b0ef7c689f6dc6f97e8..58a9cb5173efc4fe0c626ba17bd9790c6273f40c 100644
--- a/src/lib-sieve/plugins/editheader/ext-editheader-common.c
+++ b/src/lib-sieve/plugins/editheader/ext-editheader-common.c
@@ -93,18 +93,13 @@ ext_editheader_config_headers(struct sieve_instance *svinst,
 	}
 }
 
-int ext_editheader_load(const struct sieve_extension *ext, void **context)
+int ext_editheader_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct ext_editheader_context *extctx;
 	struct sieve_instance *svinst = ext->svinst;
 	size_t max_header_size;
 	pool_t pool;
 
-	if (*context != NULL) {
-		ext_editheader_unload(ext);
-		*context = NULL;
-	}
-
 	T_BEGIN {
 		pool = pool_alloconly_create("editheader_config", 1024);
 		extctx = p_new(pool, struct ext_editheader_context, 1);
@@ -139,7 +134,7 @@ int ext_editheader_load(const struct sieve_extension *ext, void **context)
 		}
 	} T_END;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/editheader/ext-editheader-common.h b/src/lib-sieve/plugins/editheader/ext-editheader-common.h
index 161d03998d2197595b2ac1283d35882004d2d50c..646db1abdfafa9e2b988f3eafc1eaedf08860d1c 100644
--- a/src/lib-sieve/plugins/editheader/ext-editheader-common.h
+++ b/src/lib-sieve/plugins/editheader/ext-editheader-common.h
@@ -26,7 +26,7 @@ extern const struct sieve_operation_def deleteheader_operation;
 
 extern const struct sieve_extension_def editheader_extension;
 
-int ext_editheader_load(const struct sieve_extension *ext, void **context);
+int ext_editheader_load(const struct sieve_extension *ext, void **context_r);
 void ext_editheader_unload(const struct sieve_extension *ext);
 
 /*
diff --git a/src/lib-sieve/plugins/enotify/ext-enotify.c b/src/lib-sieve/plugins/enotify/ext-enotify.c
index c2fa3c5d5bd583a5501d53b8c3b5da3461eb8d13..d00b12dd2e9049d4cf56307f1355beb4f82c8501 100644
--- a/src/lib-sieve/plugins/enotify/ext-enotify.c
+++ b/src/lib-sieve/plugins/enotify/ext-enotify.c
@@ -40,7 +40,8 @@ const struct sieve_operation_def *ext_enotify_operations[] = {
  * Extension
  */
 
-static int ext_enotify_load(const struct sieve_extension *ext, void **context);
+static int
+ext_enotify_load(const struct sieve_extension *ext, void **context_r);
 static void ext_enotify_unload(const struct sieve_extension *ext);
 static bool
 ext_enotify_validator_load(const struct sieve_extension *ext,
@@ -55,26 +56,22 @@ const struct sieve_extension_def enotify_extension = {
 	SIEVE_EXT_DEFINE_OPERAND(encodeurl_operand),
 };
 
-static int ext_enotify_load(const struct sieve_extension *ext, void **context)
+static int ext_enotify_load(const struct sieve_extension *ext, void **context_r)
 {
 	const struct sieve_extension *var_ext;
 	struct ext_enotify_context *extctx;
 
-	if (*context != NULL) {
-		ext_enotify_unload(ext);
-		*context = NULL;
-	}
-
 	if (sieve_ext_variables_get_extension(ext->svinst, &var_ext) < 0)
 		return -1;
 
 	extctx = i_new(struct ext_enotify_context, 1);
 	extctx->var_ext = var_ext;
-	*context = extctx;
 
 	ext_enotify_methods_init(ext->svinst, extctx);
 
 	sieve_extension_capabilities_register(ext, &notify_capabilities);
+
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/imap4flags/ext-imap4flags.c b/src/lib-sieve/plugins/imap4flags/ext-imap4flags.c
index c4cea7fccf8c2e58bff0b8ac45ac5432b7efd5d1..1968129b7b84f341605434ae61ae3e9e8661a30e 100644
--- a/src/lib-sieve/plugins/imap4flags/ext-imap4flags.c
+++ b/src/lib-sieve/plugins/imap4flags/ext-imap4flags.c
@@ -43,7 +43,7 @@ const struct sieve_operation_def *imap4flags_operations[] = {
  */
 
 static int
-ext_imap4flags_load(const struct sieve_extension *ext, void **context);
+ext_imap4flags_load(const struct sieve_extension *ext, void **context_r);
 static void ext_imap4flags_unload(const struct sieve_extension *ext);
 
 static bool ext_imap4flags_validator_load
@@ -64,24 +64,19 @@ const struct sieve_extension_def imap4flags_extension = {
 };
 
 static int
-ext_imap4flags_load(const struct sieve_extension *ext, void **context)
+ext_imap4flags_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	const struct sieve_extension *var_ext;
 	struct ext_imap4flags_context *extctx;
 
-	if (*context != NULL) {
-		ext_imap4flags_unload(ext);
-		*context = NULL;
-	}
-
 	if (sieve_ext_variables_get_extension(svinst, &var_ext) < 0)
 		return -1;
 
 	extctx = i_new(struct ext_imap4flags_context, 1);
 	extctx->var_ext = var_ext;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/include/ext-include-common.c b/src/lib-sieve/plugins/include/ext-include-common.c
index eb271d09ad34ed3210c42384843d5368405b4acf..79e684f3cc13baa1a5d84fd7a98da3f9f1fd56cf 100644
--- a/src/lib-sieve/plugins/include/ext-include-common.c
+++ b/src/lib-sieve/plugins/include/ext-include-common.c
@@ -73,7 +73,7 @@ struct ext_include_interpreter_context {
 
 /* Extension hooks */
 
-int ext_include_load(const struct sieve_extension *ext, void **context)
+int ext_include_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	const struct sieve_extension *var_ext;
@@ -81,11 +81,6 @@ int ext_include_load(const struct sieve_extension *ext, void **context)
 	const char *location;
 	unsigned long long int uint_setting;
 
-	if (*context != NULL) {
-		ext_include_unload(ext);
-		*context = NULL;
-	}
-
 	/* Extension dependencies */
 	if (sieve_ext_variables_get_extension(ext->svinst, &var_ext) < 0)
 		return -1;
@@ -115,7 +110,7 @@ int ext_include_load(const struct sieve_extension *ext, void **context)
 		svinst, "sieve_include_max_includes", &uint_setting))
 		extctx->max_includes = (unsigned int)uint_setting;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/include/ext-include-common.h b/src/lib-sieve/plugins/include/ext-include-common.h
index cc98b7763ce0a916e6a6832c3f1ef5fe06cf8f4b..9b9ca7c63507d142a6f2e204eb831cdf85baec52 100644
--- a/src/lib-sieve/plugins/include/ext-include-common.h
+++ b/src/lib-sieve/plugins/include/ext-include-common.h
@@ -53,7 +53,7 @@ ext_include_script_location_name(enum ext_include_script_location location)
 extern const struct sieve_extension_def include_extension;
 extern const struct sieve_binary_extension include_binary_ext;
 
-int ext_include_load(const struct sieve_extension *ext, void **context);
+int ext_include_load(const struct sieve_extension *ext, void **context_r);
 void ext_include_unload(const struct sieve_extension *ext);
 
 /*
diff --git a/src/lib-sieve/plugins/mime/ext-extracttext.c b/src/lib-sieve/plugins/mime/ext-extracttext.c
index c2c3e218ffd1010db1d01c7e51858226dbbe2d3f..b62b2cc9a40bb8276c60b9d1dc16f11bc008623c 100644
--- a/src/lib-sieve/plugins/mime/ext-extracttext.c
+++ b/src/lib-sieve/plugins/mime/ext-extracttext.c
@@ -31,7 +31,7 @@
  */
 
 static int
-ext_extracttext_load(const struct sieve_extension *ext, void **context);
+ext_extracttext_load(const struct sieve_extension *ext, void **context_r);
 static void
 ext_extracttext_unload(const struct sieve_extension *ext);
 static bool
@@ -47,18 +47,13 @@ const struct sieve_extension_def extracttext_extension = {
 };
 
 static int
-ext_extracttext_load(const struct sieve_extension *ext, void **context)
+ext_extracttext_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	const struct sieve_extension *var_ext;
 	const struct sieve_extension *fep_ext;
 	struct ext_extracttext_context *extctx;
 
-	if (*context != NULL) {
-		ext_extracttext_unload(ext);
-		*context = NULL;
-	}
-
 	if (sieve_ext_variables_get_extension(ext->svinst, &var_ext) < 0)
 		return -1;
 	if (sieve_extension_register(svinst, &foreverypart_extension, FALSE,
@@ -69,7 +64,7 @@ ext_extracttext_load(const struct sieve_extension *ext, void **context)
 	extctx->var_ext = var_ext;
 	extctx->fep_ext = fep_ext;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
index 48376fdfe76d1a98f670f91dec034e2f025bbadc..e6c43fa15d57dd4d9a61af329d9f321ef6974bbb 100644
--- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
+++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
@@ -37,8 +37,7 @@ struct ext_spamvirustest_header_spec {
 
 struct ext_spamvirustest_context {
 	pool_t pool;
-
-	int reload;
+	unsigned int reload_id;
 
 	struct ext_spamvirustest_header_spec status_header;
 	struct ext_spamvirustest_header_spec max_header;
@@ -249,22 +248,17 @@ ext_spamvirustest_parse_decimal_value(const char *str_value,
  * Extension initialization
  */
 
-int ext_spamvirustest_load(const struct sieve_extension *ext, void **context)
+int ext_spamvirustest_load(const struct sieve_extension *ext, void **context_r)
 {
+	static unsigned int reload_id = 0;
 	struct sieve_instance *svinst = ext->svinst;
-	struct ext_spamvirustest_context *extctx = *context;
+	struct ext_spamvirustest_context *extctx;
 	const char *ext_name, *status_header, *max_header, *status_type,
 		*max_value;
 	enum ext_spamvirustest_status_type type;
 	const char *error;
 	pool_t pool;
-	int reload = 0, ret = 0;
-
-	if (*context != NULL) {
-		reload = extctx->reload + 1;
-		ext_spamvirustest_unload(ext);
-		*context = NULL;
-	}
+	int ret = 0;
 
 	/* FIXME: Prevent loading of both spamtest and spamtestplus:
 	   let these share contexts.
@@ -343,7 +337,7 @@ int ext_spamvirustest_load(const struct sieve_extension *ext, void **context)
 	pool = pool_alloconly_create("spamvirustest_data", 512);
 	extctx = p_new(pool, struct ext_spamvirustest_context, 1);
 	extctx->pool = pool;
-	extctx->reload = reload;
+	extctx->reload_id = ++reload_id;
 	extctx->status_type = type;
 
 	if (!ext_spamvirustest_header_spec_parse(
@@ -405,14 +399,14 @@ int ext_spamvirustest_load(const struct sieve_extension *ext, void **context)
 		}
 	}
 
-	*context = extctx;
+	*context_r = extctx;
 	if (ret < 0) {
 		e_warning(svinst->event, "%s: "
 			  "extension not configured, "
 			  "tests will always match against \"0\"",
 			  ext_name);
 		ext_spamvirustest_unload(ext);
-		*context = NULL;
+		*context_r = NULL;
 	}
 
 	return ret;
@@ -435,7 +429,7 @@ void ext_spamvirustest_unload(const struct sieve_extension *ext)
  */
 
 struct ext_spamvirustest_message_context {
-	int reload;
+	unsigned int reload_id;
 	float score_ratio;
 };
 
@@ -500,7 +494,7 @@ int ext_spamvirustest_get_value(const struct sieve_runtime_env *renv,
 		/* Create new context */
 		mctx = p_new(pool, struct ext_spamvirustest_message_context, 1);
 		sieve_message_context_extension_set(msgctx, ext, mctx);
-	} else if (mctx->reload == extctx->reload) {
+	} else if (mctx->reload_id == extctx->reload_id) {
 		/* Use cached result */
 		*value_r = ext_spamvirustest_get_score(ext, mctx->score_ratio,
 						       percent);
@@ -509,7 +503,7 @@ int ext_spamvirustest_get_value(const struct sieve_runtime_env *renv,
 		/* Extension was reloaded (probably in testsuite) */
 	}
 
-	mctx->reload = extctx->reload;
+	mctx->reload_id = extctx->reload_id;
 
 	/*
 	 * Get max status value
diff --git a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.h b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.h
index 87d4844608f9cc514ca6e6c04e834b137412b72b..154ec3458240ac7e927e5f766c9c505fc8633061 100644
--- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.h
+++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.h
@@ -11,7 +11,7 @@ extern const struct sieve_extension_def spamtest_extension;
 extern const struct sieve_extension_def spamtestplus_extension;
 extern const struct sieve_extension_def virustest_extension;
 
-int ext_spamvirustest_load(const struct sieve_extension *ext, void **context);
+int ext_spamvirustest_load(const struct sieve_extension *ext, void **context_r);
 void ext_spamvirustest_unload(const struct sieve_extension *ext);
 
 /*
diff --git a/src/lib-sieve/plugins/subaddress/ext-subaddress.c b/src/lib-sieve/plugins/subaddress/ext-subaddress.c
index 34a54c1f323fb3e6524dd3de5585a7730e59244d..85e6e9a946e4db9278e2a04db5257917c32bc11c 100644
--- a/src/lib-sieve/plugins/subaddress/ext-subaddress.c
+++ b/src/lib-sieve/plugins/subaddress/ext-subaddress.c
@@ -64,16 +64,11 @@ const struct sieve_extension_def subaddress_extension = {
 };
 
 static int
-ext_subaddress_load(const struct sieve_extension *ext, void **context)
+ext_subaddress_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct ext_subaddress_context *extctx;
 	const char *delim;
 
-	if (*context != NULL) {
-		ext_subaddress_unload(ext);
-		*context = NULL;
-	}
-
 	delim = sieve_setting_get(ext->svinst, "recipient_delimiter");
 
 	if (delim == NULL)
@@ -82,7 +77,7 @@ ext_subaddress_load(const struct sieve_extension *ext, void **context)
 	extctx = i_new(struct ext_subaddress_context, 1);
 	extctx->delimiter = i_strdup(delim);
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.c b/src/lib-sieve/plugins/variables/ext-variables-common.c
index 5aa411e821d653ef170d003b0290cde3a45d0390..dab91448a15436eecb0ba1d9772b37d42b8e577c 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-common.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.c
@@ -52,18 +52,13 @@ size_t sieve_variables_get_max_variable_size(
  * Extension configuration
  */
 
-int ext_variables_load(const struct sieve_extension *ext, void **context)
+int ext_variables_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	struct ext_variables_context *extctx;
 	unsigned long long int uint_setting;
 	size_t size_setting;
 
-	if (*context != NULL) {
-		ext_variables_unload(ext);
-		*context = NULL;
-	}
-
 	extctx = i_new(struct ext_variables_context, 1);
 
 	/* Get limits */
@@ -97,7 +92,7 @@ int ext_variables_load(const struct sieve_extension *ext, void **context)
 		}
 	}
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.h b/src/lib-sieve/plugins/variables/ext-variables-common.h
index f0c1fef429654a38f383ad56545e3bd6ae22c7d4..16c6dab9a39d529792b848a2acba1414d120ed18 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-common.h
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.h
@@ -19,7 +19,7 @@ struct ext_variables_context {
 
 extern const struct sieve_extension_def variables_extension;
 
-int ext_variables_load(const struct sieve_extension *ext, void **context);
+int ext_variables_load(const struct sieve_extension *ext, void **context_r);
 void ext_variables_unload(const struct sieve_extension *ext);
 
 const struct ext_variables_context *
diff --git a/src/lib-sieve/plugins/vnd.dovecot/environment/ext-vnd-environment.c b/src/lib-sieve/plugins/vnd.dovecot/environment/ext-vnd-environment.c
index e3a81e9320055011ed6296615656f7a2af322f32..529950eeb4a61fba5696b221480b6039d05ec22a 100644
--- a/src/lib-sieve/plugins/vnd.dovecot/environment/ext-vnd-environment.c
+++ b/src/lib-sieve/plugins/vnd.dovecot/environment/ext-vnd-environment.c
@@ -36,7 +36,7 @@
  */
 
 static int
-ext_vnd_environment_load(const struct sieve_extension *ext, void **context);
+ext_vnd_environment_load(const struct sieve_extension *ext, void **context_r);
 static void
 ext_vnd_environment_unload(const struct sieve_extension *ext);
 static bool
@@ -57,17 +57,12 @@ const struct sieve_extension_def vnd_environment_extension = {
 };
 
 static int
-ext_vnd_environment_load(const struct sieve_extension *ext, void **context)
+ext_vnd_environment_load(const struct sieve_extension *ext, void **context_r)
 {
 	const struct sieve_extension *ext_env;
 	const struct sieve_extension *ext_var;
 	struct ext_vnd_environment_context *extctx;
 
-	if (*context != NULL) {
-		ext_vnd_environment_unload(ext);
-		*context = NULL;
-	}
-
 	if (sieve_ext_environment_require_extension(ext->svinst, &ext_env) < 0)
 		return -1;
 	if (sieve_ext_variables_get_extension(ext->svinst, &ext_var) < 0)
@@ -77,7 +72,7 @@ ext_vnd_environment_load(const struct sieve_extension *ext, void **context)
 	extctx->env_ext = ext_env;
 	extctx->var_ext = ext_var;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.c b/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.c
index f2d7668e936fb673cc87e1e7d2f246e285d95681..543b5c6b8a7ea5d9252fd40a4768f3d83aaa9344 100644
--- a/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.c
+++ b/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.c
@@ -10,7 +10,7 @@
 
 #include "ext-vnd-report-common.h"
 
-int ext_report_load(const struct sieve_extension *ext, void **context)
+int ext_report_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	struct ext_report_context *extctx;
@@ -21,7 +21,7 @@ int ext_report_load(const struct sieve_extension *ext, void **context)
 		svinst, svinst->pool, "sieve_report_from",
 		&extctx->report_from);
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.h b/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.h
index 09ea4d940fb499998e9bc31b4ca35772ac6d2a1f..6302a7e759e61259957f78bf464474ae48abf79b 100644
--- a/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.h
+++ b/src/lib-sieve/plugins/vnd.dovecot/report/ext-vnd-report-common.h
@@ -15,7 +15,7 @@ struct ext_report_context {
 
 extern const struct sieve_extension_def vnd_report_extension;
 
-int ext_report_load(const struct sieve_extension *ext, void **context);
+int ext_report_load(const struct sieve_extension *ext, void **context_r);
 
 /*
  * Commands
diff --git a/src/lib-sieve/sieve-extensions.c b/src/lib-sieve/sieve-extensions.c
index ac033ac48c3f3683a1e14df75c0d7d57788daecc..19e175557728de362124b339f6a11148110e0753 100644
--- a/src/lib-sieve/sieve-extensions.c
+++ b/src/lib-sieve/sieve-extensions.c
@@ -296,10 +296,16 @@ sieve_extensions_get_preloaded(struct sieve_instance *svinst,
  * Extension registry
  */
 
+static void _sieve_extension_unload(struct sieve_extension *ext);
+
 static int _sieve_extension_load(struct sieve_extension *ext)
 {
 	int ret;
 
+	/* Drop context if this is a reload */
+	if (ext->context != NULL)
+		_sieve_extension_unload(ext);
+
 	/* Call load handler */
 	if (ext->def == NULL || ext->def->load == NULL)
 		return 0;
diff --git a/src/lib-sieve/sieve-extensions.h b/src/lib-sieve/sieve-extensions.h
index fa46859a1d014e6fd30532c3c76c3fc66dfbc53a..db6d621b5e050ed3c409ddc110a0cb900ff352c6 100644
--- a/src/lib-sieve/sieve-extensions.h
+++ b/src/lib-sieve/sieve-extensions.h
@@ -24,7 +24,7 @@ struct sieve_extension_def {
 	unsigned int version;
 
 	/* Registration */
-	int (*load)(const struct sieve_extension *ext, void **context);
+	int (*load)(const struct sieve_extension *ext, void **context_r);
 	void (*unload)(const struct sieve_extension *ext);
 
 	/* Compilation */
diff --git a/src/plugins/imapsieve/ext-imapsieve.c b/src/plugins/imapsieve/ext-imapsieve.c
index a19f5ed4cbb025ebb452ed244143d66a12b90432..79dc59fd36e7570ef737fe96170ba6d662bef9b1 100644
--- a/src/plugins/imapsieve/ext-imapsieve.c
+++ b/src/plugins/imapsieve/ext-imapsieve.c
@@ -29,9 +29,9 @@
  */
 
 static int
-ext_imapsieve_load(const struct sieve_extension *ext, void **context);
+ext_imapsieve_load(const struct sieve_extension *ext, void **context_r);
 static int
-ext_vnd_imapsieve_load(const struct sieve_extension *ext, void **context);
+ext_vnd_imapsieve_load(const struct sieve_extension *ext, void **context_r);
 static void ext_imapsieve_unload(const struct sieve_extension *ext);
 static void ext_vnd_imapsieve_unload(const struct sieve_extension *ext);
 
@@ -72,16 +72,11 @@ const struct sieve_extension_def vnd_imapsieve_extension = {
  */
 
 static int
-ext_imapsieve_load(const struct sieve_extension *ext, void **context)
+ext_imapsieve_load(const struct sieve_extension *ext, void **context_r)
 {
 	const struct sieve_extension *ext_environment;
 	struct ext_imapsieve_context *extctx;
 
-	if (context != NULL) {
-		ext_imapsieve_unload(ext);
-		*context = NULL;
-	}
-
 	if (sieve_ext_environment_require_extension(ext->svinst,
 						    &ext_environment) < 0)
 		return -1;
@@ -89,20 +84,15 @@ ext_imapsieve_load(const struct sieve_extension *ext, void **context)
 	extctx = i_new(struct ext_imapsieve_context, 1);
 	extctx->ext_environment = ext_environment;
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
 static int
-ext_vnd_imapsieve_load(const struct sieve_extension *ext, void **context)
+ext_vnd_imapsieve_load(const struct sieve_extension *ext, void **context_r)
 {
 	struct ext_vnd_imapsieve_context *extctx;
 
-	if (context != NULL) {
-		ext_imapsieve_unload(ext);
-		*context = NULL;
-	}
-
 	extctx = i_new(struct ext_vnd_imapsieve_context, 1);
 #ifdef __IMAPSIEVE_DUMMY
 	if (sieve_extension_require(ext->svinst, &imapsieve_extension_dummy,
@@ -114,7 +104,7 @@ ext_vnd_imapsieve_load(const struct sieve_extension *ext, void **context)
 		return -1;
 #endif
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/plugins/sieve-extprograms/sieve-extprograms-common.c b/src/plugins/sieve-extprograms/sieve-extprograms-common.c
index e64e25f4d38a2023085a9441406347e8dd58dae7..fae2ecb31ad4b60717800c6961381af056b1b377 100644
--- a/src/plugins/sieve-extprograms/sieve-extprograms-common.c
+++ b/src/plugins/sieve-extprograms/sieve-extprograms-common.c
@@ -57,7 +57,7 @@
  */
 
 int sieve_extprograms_ext_load(const struct sieve_extension *ext,
-			       void **context)
+			       void **context_r)
 {
 	struct sieve_instance *svinst = ext->svinst;
 	const struct sieve_extension *copy_ext = NULL;
@@ -67,11 +67,6 @@ int sieve_extprograms_ext_load(const struct sieve_extension *ext,
 	const char *bin_dir, *socket_dir, *input_eol;
 	sieve_number_t execute_timeout;
 
-	if (*context != NULL) {
-		sieve_extprograms_ext_unload(ext);
-		*context = NULL;
-	}
-
 	extname = strrchr(extname, '.');
 	i_assert(extname != NULL);
 	extname++;
@@ -119,7 +114,7 @@ int sieve_extprograms_ext_load(const struct sieve_extension *ext,
 		}
 	}
 
-	*context = extctx;
+	*context_r = extctx;
 	return 0;
 }
 
diff --git a/src/plugins/sieve-extprograms/sieve-extprograms-common.h b/src/plugins/sieve-extprograms/sieve-extprograms-common.h
index c7f9719f3522d0694fde3cbd4b3749d704c68299..881b7d467585419c97f11dd7c0b42841145847c1 100644
--- a/src/plugins/sieve-extprograms/sieve-extprograms-common.h
+++ b/src/plugins/sieve-extprograms/sieve-extprograms-common.h
@@ -25,7 +25,7 @@ struct sieve_extprograms_ext_context {
 };
 
 int sieve_extprograms_ext_load(const struct sieve_extension *ext,
-			       void **context);
+			       void **context_r);
 void sieve_extprograms_ext_unload(const struct sieve_extension *ext);
 
 /*