diff --git a/src/lib-sieve/sieve-code.c b/src/lib-sieve/sieve-code.c
index 254f2ea9dc4361f32d27b7b95cd224d4a3c35798..5aaf4d07d28ebe6a8cac5942b23e073a5c348908 100644
--- a/src/lib-sieve/sieve-code.c
+++ b/src/lib-sieve/sieve-code.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+ 
 #include "lib.h"
 #include "str.h"
 #include "str-sanitize.h"
@@ -75,7 +78,7 @@ void sieve_coded_stringlist_reset(struct sieve_coded_stringlist *strlist)
 }
 
 int sieve_coded_stringlist_get_length
-	(struct sieve_coded_stringlist *strlist)
+(struct sieve_coded_stringlist *strlist)
 {
 	return strlist->length;
 }
@@ -87,7 +90,7 @@ sieve_size_t sieve_coded_stringlist_get_end_address
 }
 
 sieve_size_t sieve_coded_stringlist_get_current_offset
-	(struct sieve_coded_stringlist *strlist)
+(struct sieve_coded_stringlist *strlist)
 {
 	return strlist->current_offset;
 }
@@ -146,7 +149,7 @@ static bool sieve_coded_stringlist_dump
 }
 	
 /*
- * Source line
+ * Source line coding
  */
 
 void sieve_code_source_line_emit
@@ -176,7 +179,7 @@ bool sieve_code_source_line_read
 {
 	sieve_size_t number;
 
-    if ( !sieve_binary_read_integer(renv->sbin, address, &number) )
+	if ( !sieve_binary_read_integer(renv->sbin, address, &number) )
 		return FALSE;
 
 	*source_line = number;
@@ -190,6 +193,7 @@ bool sieve_code_source_line_read
 const struct sieve_operand number_operand;
 const struct sieve_operand string_operand;
 const struct sieve_operand stringlist_operand;
+
 extern const struct sieve_operand comparator_operand;
 extern const struct sieve_operand match_type_operand;
 extern const struct sieve_operand address_part_operand;
@@ -212,7 +216,7 @@ const unsigned int sieve_operand_count =
  */
 
 sieve_size_t sieve_operand_emit_code
-	(struct sieve_binary *sbin, const struct sieve_operand *opr)
+(struct sieve_binary *sbin, const struct sieve_operand *opr)
 {
 	sieve_size_t address;
 
@@ -230,7 +234,7 @@ sieve_size_t sieve_operand_emit_code
 }
 
 const struct sieve_operand *sieve_operand_read
-	(struct sieve_binary *sbin, sieve_size_t *address) 
+(struct sieve_binary *sbin, sieve_size_t *address) 
 {
 	const struct sieve_extension *ext;
 	unsigned int code = sieve_operand_count;
@@ -246,7 +250,7 @@ const struct sieve_operand *sieve_operand_read
 }
 
 bool sieve_operand_optional_present
-	(struct sieve_binary *sbin, sieve_size_t *address)
+(struct sieve_binary *sbin, sieve_size_t *address)
 {	
 	sieve_size_t tmp_addr = *address;
 	unsigned int op = -1;
@@ -261,7 +265,7 @@ bool sieve_operand_optional_present
 }
 
 bool sieve_operand_optional_read
-	(struct sieve_binary *sbin, sieve_size_t *address, int *id_code)
+(struct sieve_binary *sbin, sieve_size_t *address, int *id_code)
 {
 	if ( sieve_binary_read_code(sbin, address, id_code) ) 
 		return TRUE;
@@ -456,7 +460,7 @@ bool sieve_opr_string_dump_data
 }
 
 bool sieve_opr_string_dump
-	(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
+(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
 {
 	const struct sieve_operand *operand;
 	
@@ -503,7 +507,7 @@ static void _dump_string
 }
 
 bool opr_string_dump
-	(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
+(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
 {
 	string_t *str; 
 	
@@ -517,7 +521,7 @@ bool opr_string_dump
 }
 
 static bool opr_string_read
-  (const struct sieve_runtime_env *renv, sieve_size_t *address, string_t **str)
+(const struct sieve_runtime_env *renv, sieve_size_t *address, string_t **str)
 { 	
 	return sieve_binary_read_string(renv->sbin, address, str);
 }
@@ -541,13 +545,13 @@ void sieve_opr_stringlist_emit_start
 }
 
 void sieve_opr_stringlist_emit_item
-	(struct sieve_binary *sbin, void *context ATTR_UNUSED, string_t *item)
+(struct sieve_binary *sbin, void *context ATTR_UNUSED, string_t *item)
 {
 	(void) sieve_opr_string_emit(sbin, item);
 }
 
 void sieve_opr_stringlist_emit_end
-	(struct sieve_binary *sbin, void *context)
+(struct sieve_binary *sbin, void *context)
 {
 	sieve_size_t *end_offset = (sieve_size_t *) context;
 
@@ -583,7 +587,7 @@ bool sieve_opr_stringlist_dump_data
 }
 
 bool sieve_opr_stringlist_dump
-	(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
+(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
 {
 	const struct sieve_operand *operand;
 
@@ -594,8 +598,8 @@ bool sieve_opr_stringlist_dump
 }
 
 struct sieve_coded_stringlist *sieve_opr_stringlist_read_data
-  (const struct sieve_runtime_env *renv, const struct sieve_operand *operand,
-  	sieve_size_t op_address, sieve_size_t *address)
+(const struct sieve_runtime_env *renv, const struct sieve_operand *operand,
+	sieve_size_t op_address, sieve_size_t *address)
 {
 	if ( operand == NULL )
 		return NULL;
@@ -624,7 +628,7 @@ struct sieve_coded_stringlist *sieve_opr_stringlist_read_data
 }
 
 struct sieve_coded_stringlist *sieve_opr_stringlist_read
-  (const struct sieve_runtime_env *renv, sieve_size_t *address)
+(const struct sieve_runtime_env *renv, sieve_size_t *address)
 {
 	sieve_size_t op_address = *address;
 	const struct sieve_operand *operand = sieve_operand_read(renv->sbin, address);
@@ -633,7 +637,7 @@ struct sieve_coded_stringlist *sieve_opr_stringlist_read
 }
 
 static bool opr_stringlist_dump
-	(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
+(const struct sieve_dumptime_env *denv, sieve_size_t *address) 
 {
 	sieve_size_t pc = *address;
 	sieve_size_t end; 
@@ -652,7 +656,7 @@ static bool opr_stringlist_dump
 }
 
 static struct sieve_coded_stringlist *opr_stringlist_read
-  (const struct sieve_runtime_env *renv, sieve_size_t *address )
+(const struct sieve_runtime_env *renv, sieve_size_t *address )
 {
 	struct sieve_coded_stringlist *strlist;
 	sieve_size_t pc = *address;
@@ -677,10 +681,10 @@ static struct sieve_coded_stringlist *opr_stringlist_read
 }  
 
 /* 
- * Operations
+ * Core operations
  */
  
-/* Declaration of opcodes defined in this file */
+/* Forward declarations */
 
 static bool opc_jmp_dump
 	(const struct sieve_operation *op, 
@@ -696,6 +700,8 @@ static int opc_jmpfalse_execute
 	(const struct sieve_operation *op, 
 		const struct sieve_runtime_env *renv, sieve_size_t *address);
 
+/* Operation objects defined in this file */
+
 const struct sieve_operation sieve_jmp_operation = { 
 	"JMP",
 	NULL,
@@ -719,6 +725,8 @@ const struct sieve_operation sieve_jmpfalse_operation = {
 	opc_jmp_dump, 
 	opc_jmpfalse_execute 
 };
+
+/* Operation objects defined in other files */
 	
 extern const struct sieve_operation cmd_stop_operation;
 extern const struct sieve_operation cmd_keep_operation;
@@ -753,10 +761,12 @@ const struct sieve_operation *sieve_operations[] = {
 const unsigned int sieve_operation_count =
 	N_ELEMENTS(sieve_operations);
 
-/* Operation functions */
+/* 
+ * Operation functions 
+ */
 
 sieve_size_t sieve_operation_emit_code
-	(struct sieve_binary *sbin, const struct sieve_operation *op)
+(struct sieve_binary *sbin, const struct sieve_operation *op)
 {
 	sieve_size_t address;
 
@@ -774,7 +784,7 @@ sieve_size_t sieve_operation_emit_code
 }
 
 const struct sieve_operation *sieve_operation_read
-	(struct sieve_binary *sbin, sieve_size_t *address) 
+(struct sieve_binary *sbin, sieve_size_t *address) 
 {
 	const struct sieve_extension *ext;
 	unsigned int code = sieve_operation_count;
@@ -788,8 +798,12 @@ const struct sieve_operation *sieve_operation_read
     return (const struct sieve_operation *) sieve_binary_read_extension_object
         (sbin, address, &ext->operations);
 }
+
+/*
+ * Jump operations
+ */
 	
-/* Code dump for core commands */
+/* Code dump */
 
 static bool opc_jmp_dump
 (const struct sieve_operation *op,
@@ -807,19 +821,7 @@ static bool opc_jmp_dump
 	return TRUE;
 }	
 			
-/* Code dump for trivial operations */
-
-bool sieve_operation_string_dump
-(const struct sieve_operation *op,
-	const struct sieve_dumptime_env *denv, sieve_size_t *address)
-{
-	sieve_code_dumpf(denv, "%s", op->mnemonic);
-
-	return 
-		sieve_opr_string_dump(denv, address);
-}
-
-/* Code execution for core commands */
+/* Code execution */
 
 static int opc_jmp_execute
 (const struct sieve_operation *op ATTR_UNUSED, 
@@ -851,3 +853,20 @@ static int opc_jmpfalse_execute
 	
 	return sieve_interpreter_program_jump(renv->interp, !result);
 }	
+
+/*
+ * Utility
+ */
+
+/* Code dump for trivial operations */
+
+bool sieve_operation_string_dump
+(const struct sieve_operation *op,
+	const struct sieve_dumptime_env *denv, sieve_size_t *address)
+{
+	sieve_code_dumpf(denv, "%s", op->mnemonic);
+
+	return 
+		sieve_opr_string_dump(denv, address);
+}
+
diff --git a/src/lib-sieve/sieve-code.h b/src/lib-sieve/sieve-code.h
index 1f57c3b84e483185201ae57ea47226cb11f0f63b..bf021dba40b8835e5b02e3cd2270dc8ba3d3d652 100644
--- a/src/lib-sieve/sieve-code.h
+++ b/src/lib-sieve/sieve-code.h
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+ 
 #ifndef __SIEVE_CODE_H
 #define __SIEVE_CODE_H
 
@@ -8,7 +11,9 @@
 
 #include "sieve-common.h"
 
-/* String list */
+/* 
+ * Coded string list 
+ */
 
 struct sieve_coded_stringlist;
 
@@ -27,7 +32,9 @@ sieve_size_t sieve_coded_stringlist_get_end_address
 sieve_size_t sieve_coded_stringlist_get_current_offset
 	(struct sieve_coded_stringlist *strlist);
 
-/* Source line */
+/* 
+ * Source line coding
+ */
 
 void sieve_code_source_line_emit
 	(struct sieve_binary *sbin, unsigned int source_line);
@@ -37,7 +44,9 @@ bool sieve_code_source_line_read
 	(const struct sieve_runtime_env *renv, sieve_size_t *address, 
     	unsigned int *source_line);
 
-/* Operand: argument to an operation */
+/* 
+ * Operand object
+ */
 
 struct sieve_operand_class {
 	const char *name;
@@ -53,28 +62,21 @@ struct sieve_operand {
 	const void *interface;
 };
 
-struct sieve_opr_number_interface {
-	bool (*dump)	
-		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
-	bool (*read)
-	  (const struct sieve_runtime_env *renv, sieve_size_t *address, 
-	  	sieve_size_t *number);
-};
+sieve_size_t sieve_operand_emit_code
+	(struct sieve_binary *sbin, const struct sieve_operand *opr);
+const struct sieve_operand *sieve_operand_read
+	(struct sieve_binary *sbin, sieve_size_t *address);
 
-struct sieve_opr_string_interface {
-	bool (*dump)
-		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
-	bool (*read)
-		(const struct sieve_runtime_env *renv, sieve_size_t *address, 
-			string_t **str);
-};
+bool sieve_operand_optional_present
+	(struct sieve_binary *sbin, sieve_size_t *address);
+bool sieve_operand_optional_read	
+	(struct sieve_binary *sbin, sieve_size_t *address, int *id_code);
 
-struct sieve_opr_stringlist_interface {
-	bool (*dump)
-		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
-	struct sieve_coded_stringlist *(*read)
-		(const struct sieve_runtime_env *renv, sieve_size_t *address);
-};
+/*
+ * Core operands
+ */
+ 
+/* Operand codes */
 
 enum sieve_core_operand {
 	SIEVE_OPERAND_OPTIONAL,
@@ -88,10 +90,14 @@ enum sieve_core_operand {
 	SIEVE_OPERAND_CUSTOM
 };
 
+/* Operand classes */
+
 const struct sieve_operand_class number_class;
 const struct sieve_operand_class string_class;
 const struct sieve_operand_class stringlist_class;
 
+/* Operand objects */
+
 extern const struct sieve_operand number_operand;
 extern const struct sieve_operand string_operand;
 extern const struct sieve_operand stringlist_operand;
@@ -99,15 +105,36 @@ extern const struct sieve_operand stringlist_operand;
 extern const struct sieve_operand *sieve_operands[];
 extern const unsigned int sieve_operand_count;
 
-sieve_size_t sieve_operand_emit_code
-	(struct sieve_binary *sbin, const struct sieve_operand *opr);
-const struct sieve_operand *sieve_operand_read
-	(struct sieve_binary *sbin, sieve_size_t *address);
+/* Operand object interfaces */
 
-bool sieve_operand_optional_present
-	(struct sieve_binary *sbin, sieve_size_t *address);
-bool sieve_operand_optional_read	
-	(struct sieve_binary *sbin, sieve_size_t *address, int *id_code);
+struct sieve_opr_number_interface {
+	bool (*dump)	
+		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
+	bool (*read)
+	  (const struct sieve_runtime_env *renv, sieve_size_t *address, 
+	  	sieve_size_t *number);
+};
+
+struct sieve_opr_string_interface {
+	bool (*dump)
+		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
+	bool (*read)
+		(const struct sieve_runtime_env *renv, sieve_size_t *address, 
+			string_t **str);
+};
+
+struct sieve_opr_stringlist_interface {
+	bool (*dump)
+		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
+	struct sieve_coded_stringlist *(*read)
+		(const struct sieve_runtime_env *renv, sieve_size_t *address);
+};
+
+/* 
+ * Core operand functions 
+ */
+
+/* Number */
 
 void sieve_opr_number_emit(struct sieve_binary *sbin, sieve_size_t number);
 bool sieve_opr_number_dump_data	
@@ -122,6 +149,14 @@ bool sieve_opr_number_read
 	(const struct sieve_runtime_env *renv, sieve_size_t *address, 
 		sieve_size_t *number);
 
+static inline bool sieve_operand_is_number
+(const struct sieve_operand *operand)
+{
+	return ( operand != NULL && operand->class == &number_class );
+}
+
+/* String */
+
 void sieve_opr_string_emit(struct sieve_binary *sbin, string_t *str);
 bool sieve_opr_string_dump_data
 	(const struct sieve_dumptime_env *denv, const struct sieve_operand *operand,
@@ -134,6 +169,14 @@ bool sieve_opr_string_read_data
 bool sieve_opr_string_read
 	(const struct sieve_runtime_env *renv, sieve_size_t *address, string_t **str);
 
+static inline bool sieve_operand_is_string
+(const struct sieve_operand *operand)
+{
+	return ( operand != NULL && operand->class == &string_class );
+}
+
+/* String list */
+
 void sieve_opr_stringlist_emit_start
 	(struct sieve_binary *sbin, unsigned int listlen, void **context);
 void sieve_opr_stringlist_emit_item
@@ -151,18 +194,6 @@ struct sieve_coded_stringlist *sieve_opr_stringlist_read_data
 struct sieve_coded_stringlist *sieve_opr_stringlist_read
 	(const struct sieve_runtime_env *renv, sieve_size_t *address);
 
-static inline bool sieve_operand_is_number
-(const struct sieve_operand *operand)
-{
-	return ( operand != NULL && operand->class == &number_class );
-}
-
-static inline bool sieve_operand_is_string
-(const struct sieve_operand *operand)
-{
-	return ( operand != NULL && operand->class == &string_class );
-}
-
 static inline bool sieve_operand_is_stringlist
 (const struct sieve_operand *operand)
 {
@@ -170,8 +201,36 @@ static inline bool sieve_operand_is_stringlist
 		(operand->class == &stringlist_class || operand->class == &string_class) );
 }
 
+/*
+ * Operation object
+ */
+ 
+struct sieve_operation {
+	const char *mnemonic;
+	
+	const struct sieve_extension *extension;
+	unsigned int code;
+	
+	bool (*dump)
+		(const struct sieve_operation *op, 
+			const struct sieve_dumptime_env *denv, sieve_size_t *address);
+	int (*execute)
+		(const struct sieve_operation *op, 
+			const struct sieve_runtime_env *renv, sieve_size_t *address);
+};
+
+sieve_size_t sieve_operation_emit_code
+	(struct sieve_binary *sbin, const struct sieve_operation *op);	
+const struct sieve_operation *sieve_operation_read
+	(struct sieve_binary *sbin, sieve_size_t *address);
+const char *sieve_operation_read_string
+    (struct sieve_binary *sbin, sieve_size_t *address);
 
-/* Operation: identifies what's to be done */
+/* 
+ * Core operations 
+ */
+
+/* Opcodes */
 
 enum sieve_operation_code {
 	SIEVE_OPERATION_INVALID,
@@ -193,38 +252,21 @@ enum sieve_operation_code {
 	SIEVE_OPERATION_CUSTOM
 };
 
-struct sieve_operation {
-	const char *mnemonic;
-	
-	const struct sieve_extension *extension;
-	unsigned int code;
-	
-	bool (*dump)
-		(const struct sieve_operation *op, 
-			const struct sieve_dumptime_env *denv, sieve_size_t *address);
-	int (*execute)
-		(const struct sieve_operation *op, 
-			const struct sieve_runtime_env *renv, sieve_size_t *address);
-};
-
-extern const struct sieve_operation *sieve_operations[];
-extern const unsigned int sieve_operations_count;
+/* Operation objects */
 
 extern const struct sieve_operation sieve_jmp_operation;
 extern const struct sieve_operation sieve_jmptrue_operation;
 extern const struct sieve_operation sieve_jmpfalse_operation; 
 
-sieve_size_t sieve_operation_emit_code
-	(struct sieve_binary *sbin, const struct sieve_operation *op);	
-const struct sieve_operation *sieve_operation_read
-	(struct sieve_binary *sbin, sieve_size_t *address);
-const char *sieve_operation_read_string
-    (struct sieve_binary *sbin, sieve_size_t *address);
+extern const struct sieve_operation *sieve_operations[];
+extern const unsigned int sieve_operations_count;
+
+/*
+ * Utilitity
+ */
 
 bool sieve_operation_string_dump
 	(const struct sieve_operation *op,
 		const struct sieve_dumptime_env *denv, sieve_size_t *address);
 
-/* Core operands */
-
 #endif