diff --git a/src/lib-sieve/plugins/include/ext-include-variables.c b/src/lib-sieve/plugins/include/ext-include-variables.c
index 53847f512fcee5a9272bad4f7b1c5e32b04471ab..4ef36dae5248dd57cfecda8173cee6db87506751 100644
--- a/src/lib-sieve/plugins/include/ext-include-variables.c
+++ b/src/lib-sieve/plugins/include/ext-include-variables.c
@@ -46,7 +46,7 @@ struct sieve_variable *ext_include_variable_import_global
 		sieve_command_validate_error(valdtr, cmd,
 			"declaration of new global variable '%s' exceeds the limit "
 			"(max variables: %u)", 
-			variable, SIEVE_VARIABLES_MAX_SCOPE_SIZE);
+			variable, sieve_variables_get_max_scope_size());
 		return NULL;
 	}
 	
@@ -107,10 +107,10 @@ bool ext_include_variables_load
 		return FALSE;
 	}
 
-	if ( count > SIEVE_VARIABLES_MAX_SCOPE_SIZE ) {
+	if ( count > sieve_variables_get_max_scope_size() ) {
 		sieve_sys_error("include: global variable scope size of binary %s "
 			"exceeds the limit (%u > %u)", sieve_binary_path(sbin),
-			count, SIEVE_VARIABLES_MAX_SCOPE_SIZE );
+			count, sieve_variables_get_max_scope_size() );
 		return FALSE;
 	}
 
@@ -228,7 +228,7 @@ bool vnspc_global_variables_validate
 		sieve_argument_validate_error(valdtr, arg, 
 			"(implicit) declaration of new global variable '%s' exceeds the limit "
 			"(max variables: %u)", variable, 
-			SIEVE_VARIABLES_MAX_SCOPE_SIZE);
+			sieve_variables_get_max_scope_size());
 		return FALSE;
 	}
 	
diff --git a/src/lib-sieve/plugins/variables/cmd-set.c b/src/lib-sieve/plugins/variables/cmd-set.c
index a123367e23ef395f91e327d8425fca1cf489ccd8..5476be283a21145f84ee596836f12429b4fba1a6 100644
--- a/src/lib-sieve/plugins/variables/cmd-set.c
+++ b/src/lib-sieve/plugins/variables/cmd-set.c
@@ -19,6 +19,7 @@
 #include "sieve-dump.h"
 
 #include "ext-variables-common.h"
+#include "ext-variables-limits.h"
 #include "ext-variables-modifiers.h"
 
 /* 
@@ -316,8 +317,8 @@ static int cmd_set_operation_execute
 	sieve_runtime_trace(renv, "SET action");
 
 	/* Hold value within limits */
-	if ( str_len(value) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE )
-		str_truncate(value, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+	if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+		str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 
 	T_BEGIN {
 		/* Apply modifiers if necessary (sorted during code generation already) */
@@ -346,8 +347,8 @@ static int cmd_set_operation_execute
 						break;
 
 					/* Hold value within limits */
-					if ( str_len(value) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE )
-						str_truncate(value, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+					if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+						str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 				}
 			}
 		}	
diff --git a/src/lib-sieve/plugins/variables/ext-variables-arguments.c b/src/lib-sieve/plugins/variables/ext-variables-arguments.c
index 49c9c8594cad615adaf8d92ebb4e3867133750b8..70f91eac054578d2913ec8b8e32672a0a2bc4462 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-arguments.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-arguments.c
@@ -48,7 +48,7 @@ static bool ext_variables_variable_argument_activate
 		sieve_argument_validate_error(valdtr, arg, 
 			"(implicit) declaration of new variable '%s' exceeds the limit "
 			"(max variables: %u)", variable, 
-			SIEVE_VARIABLES_MAX_SCOPE_SIZE);
+			EXT_VARIABLES_MAX_SCOPE_SIZE);
 		return FALSE;
 	}
 	
@@ -114,10 +114,10 @@ static bool ext_variables_match_value_argument_activate
 		return FALSE;
 	}
 
-	if ( index > SIEVE_VARIABLES_MAX_MATCH_INDEX ) {
+	if ( index > EXT_VARIABLES_MAX_MATCH_INDEX ) {
 		sieve_argument_validate_error(valdtr, arg, 
 			"match value index %u out of range (max: %u)", index, 
-			SIEVE_VARIABLES_MAX_MATCH_INDEX);
+			EXT_VARIABLES_MAX_MATCH_INDEX);
 		return FALSE;
 	} 
 
diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.c b/src/lib-sieve/plugins/variables/ext-variables-common.c
index 040412e543a174eb7397dc0f96f42e48792eab34..051612c98c2076723619ec7610815f4404e58fd7 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-common.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.c
@@ -21,9 +21,19 @@
 #include "sieve-interpreter.h"
 
 #include "ext-variables-common.h"
+#include "ext-variables-limits.h"
 #include "ext-variables-name.h"
 #include "ext-variables-modifiers.h"
 
+/*
+ * Limits
+ */
+
+unsigned int sieve_variables_get_max_scope_size(void)
+{ 
+	return EXT_VARIABLES_MAX_SCOPE_SIZE;
+}
+
 /*
  * Variable scope 
  */
@@ -95,7 +105,7 @@ struct sieve_variable *sieve_variable_scope_declare
 	new_var = p_new(scope->pool, struct sieve_variable, 1);
 	new_var->ext = scope->ext;
 
-	if ( array_count(&scope->variable_index) >= SIEVE_VARIABLES_MAX_SCOPE_SIZE ) {
+	if ( array_count(&scope->variable_index) >= EXT_VARIABLES_MAX_SCOPE_SIZE ) {
 		if ( scope->error_var == NULL ) {
 			new_var->identifier = "@ERROR@";
 			new_var->index = 0;
@@ -311,8 +321,8 @@ bool sieve_variable_assign
 	str_append_str(varval, value);
 
 	/* Just a precaution, caller should prevent this in the first place */
-	if ( str_len(varval) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE )
-		str_truncate(varval, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+	if ( str_len(varval) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+		str_truncate(varval, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 
 	return TRUE;
 }
@@ -510,9 +520,9 @@ bool ext_variables_interpreter_load
 		return FALSE;
 	}
 
-	if ( scope_size > SIEVE_VARIABLES_MAX_SCOPE_SIZE ) {
+	if ( scope_size > EXT_VARIABLES_MAX_SCOPE_SIZE ) {
 		sieve_sys_error("variables: scope size exceeds the limit (%u > %u)", 
-			scope_size, SIEVE_VARIABLES_MAX_SCOPE_SIZE );
+			scope_size, EXT_VARIABLES_MAX_SCOPE_SIZE );
 		return FALSE;
 	}
 	
diff --git a/src/lib-sieve/plugins/variables/ext-variables-limits.h b/src/lib-sieve/plugins/variables/ext-variables-limits.h
index 341300ec3773c2e4cc7517f2f0cff571b88b78f6..e1b09a17c53d9ffa8dce926097cdd963f8b25135 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-limits.h
+++ b/src/lib-sieve/plugins/variables/ext-variables-limits.h
@@ -24,11 +24,11 @@
  *  as a syntax error, which SHOULD be discovered at compile-time.
  */
 
-#define SIEVE_VARIABLES_MAX_SCOPE_SIZE              255
-#define SIEVE_VARIABLES_MAX_VARIABLE_NAME_LEN       64
-#define SIEVE_VARIABLES_MAX_VARIABLE_SIZE           (4 * 1024)
-#define SIEVE_VARIABLES_MAX_NAMESPACE_ELEMENTS      4
+#define EXT_VARIABLES_MAX_SCOPE_SIZE              255
+#define EXT_VARIABLES_MAX_VARIABLE_NAME_LEN       64
+#define EXT_VARIABLES_MAX_VARIABLE_SIZE           (4 * 1024)
+#define EXT_VARIABLES_MAX_NAMESPACE_ELEMENTS      4
 
-#define SIEVE_VARIABLES_MAX_MATCH_INDEX             SIEVE_MAX_MATCH_VALUES
+#define EXT_VARIABLES_MAX_MATCH_INDEX             SIEVE_MAX_MATCH_VALUES
 
 #endif /* __EXT_VARIABLES_LIMITS_H */
diff --git a/src/lib-sieve/plugins/variables/ext-variables-name.c b/src/lib-sieve/plugins/variables/ext-variables-name.c
index 16a166241cf8cb5e8a3c9185ef2e1ccded060bf2..2c2d5cf3531e0d9f7560ef5ff997e4f9ef77a666 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-name.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-name.c
@@ -26,7 +26,7 @@ int ext_variable_name_parse
 
 		/* Acquire current position in the array */
 
-		if ( array_count(vname) >= SIEVE_VARIABLES_MAX_NAMESPACE_ELEMENTS )
+		if ( array_count(vname) >= EXT_VARIABLES_MAX_NAMESPACE_ELEMENTS )
 			return -1;
 
 		cur_element = array_append_space(vname);
@@ -42,7 +42,7 @@ int ext_variable_name_parse
 			p++;
 		
 			while ( p < strend && (*p == '_' || i_isalnum(*p)) ) {
-				if ( str_len(cur_ident) >= SIEVE_VARIABLES_MAX_VARIABLE_NAME_LEN )
+				if ( str_len(cur_ident) >= EXT_VARIABLES_MAX_VARIABLE_NAME_LEN )
 					return -1;
 				str_append_c(cur_ident, *p);
 				p++;
diff --git a/src/lib-sieve/plugins/variables/ext-variables-operands.c b/src/lib-sieve/plugins/variables/ext-variables-operands.c
index 1275270492df45c7e7fabd5e96a50c67932e1963..a3f79041489ed1b12a3e6f4646b9b2c5ee674c6d 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-operands.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-operands.c
@@ -19,6 +19,7 @@
 #include "sieve-interpreter.h"
 
 #include "ext-variables-common.h"
+#include "ext-variables-limits.h"
 #include "ext-variables-name.h"
 #include "ext-variables-dump.h"
 #include "ext-variables-operands.h"
@@ -242,8 +243,8 @@ static bool opr_match_value_read
 		
 			if ( *str == NULL ) 
 				*str = t_str_new(0);
-			else if ( str_len(*str) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE ) 
-				str_truncate(*str, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+			else if ( str_len(*str) > EXT_VARIABLES_MAX_VARIABLE_SIZE ) 
+				str_truncate(*str, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 		}
 		return TRUE;
 	}
diff --git a/src/lib-sieve/plugins/variables/sieve-ext-variables.h b/src/lib-sieve/plugins/variables/sieve-ext-variables.h
index 64c83d946b8deeebe1733b5c6adcfbf38f3952df..1fefc202c9aaf3a82111b9c4feb11a722848b151 100644
--- a/src/lib-sieve/plugins/variables/sieve-ext-variables.h
+++ b/src/lib-sieve/plugins/variables/sieve-ext-variables.h
@@ -13,7 +13,11 @@
 #include "sieve-objects.h"
 #include "sieve-code.h"
 
-#include "ext-variables-limits.h"
+/*
+ * Limits
+ */
+
+unsigned int sieve_variables_get_max_scope_size(void);
 
 /*
  * Variable extension