diff --git a/src/sieve-bin/bin-common.c b/src/sieve-bin/bin-common.c
index 47f9622b485870bda0891453e8b7d601ff1deca7..7deb5dd6a7af74fbdbb1550e53d4ac6c1e806dbb 100644
--- a/src/sieve-bin/bin-common.c
+++ b/src/sieve-bin/bin-common.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 #include "lib.h"
 #include "lib-signals.h"
 #include "ioloop.h"
@@ -14,7 +17,7 @@
 #include <fcntl.h>
 #include <pwd.h>
 
-/* Functionality common to all sieve test binaries */
+/* Functionality common to all sieve test tools */
 
 /* FIXME: this file is currently very messy */
 
diff --git a/src/sieve-bin/bin-common.h b/src/sieve-bin/bin-common.h
index 0457b4b6cc2e996e325d7353da3309773f7778e6..0d7076110634ab543713f9fdb53135e304fcb694 100644
--- a/src/sieve-bin/bin-common.h
+++ b/src/sieve-bin/bin-common.h
@@ -1,9 +1,12 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 #ifndef __BIN_COMMON_H
 #define __BIN_COMMON_H
 
 #include "sieve.h"
 
-/* Functionality common to all sieve test binaries */
+/* Functionality common to all sieve test tools */
 
 void bin_init(void);
 void bin_deinit(void);
diff --git a/src/sieve-bin/mail-raw.c b/src/sieve-bin/mail-raw.c
index 693ad63c70809d16e6b361a93f438b238f07f3a8..9dbb4878bfebf62196d0148543bf3a0ca07f31e4 100644
--- a/src/sieve-bin/mail-raw.c
+++ b/src/sieve-bin/mail-raw.c
@@ -1,10 +1,11 @@
-/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
 
 /* This file was gratefully stolen from dovecot/src/deliver/deliver.c and altered
  * to suit our needs. So, this contains lots and lots of duplicated code. 
- * The sieve_test program needs to read an email message from stdin and it needs 
- * to build a struct mail (to be fed to the sieve library). Deliver does something
- * similar already, so that source was a basis for this test binary. 
+ * The sieve-test and sieve-exec programs need to read an email message from stdin 
+ * and needs to build a struct mail (to be fed to the sieve library). Deliver does 
+ * something similar already, so that source was a basis for these test tools. 
  */
 
 #include "lib.h"
@@ -26,12 +27,20 @@
 #include <fcntl.h>
 #include <pwd.h>
 
+/*
+ * Configuration
+ */
+
 #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON"
 
 /* After buffer grows larger than this, create a temporary file to /tmp
    where to read the mail. */
 #define MAIL_MAX_MEMORY_BUFFER (1024*128)
 
+/*
+ * Raw mail implementation
+ */
+
 static struct istream *create_raw_stream(int fd)
 {
 	struct istream *input, *input2, *input_list[2];
diff --git a/src/sieve-bin/mail-raw.h b/src/sieve-bin/mail-raw.h
index 47e149f8f4e75fddf04206d251bbcf0fbdc3dd92..05017404765735ec0d702a0169e2188511338e85 100644
--- a/src/sieve-bin/mail-raw.h
+++ b/src/sieve-bin/mail-raw.h
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 #ifndef __MAIL_RAW_H
 #define __MAIL_RAW_H
 
diff --git a/src/sieve-bin/namespaces.c b/src/sieve-bin/namespaces.c
index f032b3e85c6c0186d788c323ad31686059ce2394..660f50a9989a511b05a3cb36624a07503c9b5ce0 100644
--- a/src/sieve-bin/namespaces.c
+++ b/src/sieve-bin/namespaces.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
 
 #include "lib.h"
 #include "istream.h"
@@ -23,7 +24,9 @@
 
 #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON"
 
-/* Hideous .... */
+/* Initialization of available mail storage and mailbox list
+ * formats. 
+ */
 
 extern struct mail_storage raw_storage;
 extern struct mail_storage maildir_storage;
@@ -38,9 +41,9 @@ extern struct mailbox_list maildir_mailbox_list;
 extern struct mailbox_list fs_mailbox_list;
 void index_mailbox_list_init(void);
 void mailbox_list_register_all(void) {
-mailbox_list_register(&maildir_mailbox_list);
-mailbox_list_register(&fs_mailbox_list);
-index_mailbox_list_init();
+	mailbox_list_register(&maildir_mailbox_list);
+	mailbox_list_register(&fs_mailbox_list);
+	index_mailbox_list_init();
 }
 
 void namespaces_init(void) 
diff --git a/src/sieve-bin/namespaces.h b/src/sieve-bin/namespaces.h
index 81e9fc030b602c2c08f45647209fd297e1947f51..572127f203854f2ad936b2a6a46f32c1a948140b 100644
--- a/src/sieve-bin/namespaces.h
+++ b/src/sieve-bin/namespaces.h
@@ -4,4 +4,4 @@
 void namespaces_init(void);
 void namespaces_deinit(void);
 
-#endif /* __MAIL_RAW_H */
+#endif /* __NAMESPACES_H */
diff --git a/src/sieve-bin/sieve-exec.c b/src/sieve-bin/sieve-exec.c
index aad34b0886ba745592f1b37d74ef17a3999c9095..193635220462521194dd4789dff15d1bdfbdf2a3 100644
--- a/src/sieve-bin/sieve-exec.c
+++ b/src/sieve-bin/sieve-exec.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
 
 #include "lib.h"
 #include "ostream.h"
@@ -18,10 +19,13 @@
 #include <fcntl.h>
 #include <pwd.h>
 
-
 #define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail"
 #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON"
 
+/*
+ * Dummy SMTP session
+ */
+
 static void *sieve_smtp_open(const char *destination,
 	const char *return_path, FILE **file_r)
 {
@@ -41,6 +45,10 @@ static bool sieve_smtp_close(void *handle ATTR_UNUSED)
 	return TRUE;
 }
 
+/*
+ * Dummy duplicate check implementation
+ */
+
 static int duplicate_check(const void *id ATTR_UNUSED, size_t id_size ATTR_UNUSED, 
 	const char *user)
 {
@@ -55,6 +63,10 @@ static void duplicate_mark
 	i_info("marked duplicate for user %s.\n", user);
 }
 
+/*
+ * Print help 
+ */
+
 static void print_help(void)
 {
 	printf(
@@ -64,6 +76,10 @@ static void print_help(void)
 	);
 }
 
+/*
+ * Tool implementation
+ */
+
 int main(int argc, char **argv) 
 {
 	const char *scriptfile, *recipient, *sender, *mailbox, *dumpfile, *mailfile;
@@ -147,6 +163,7 @@ int main(int argc, char **argv)
 
 	namespaces_init();
 
+	/* Obtain mail namespaces from -l argument */
 	if ( mailloc != NULL ) {
 		struct mail_user *mail_user;
 
@@ -165,6 +182,7 @@ int main(int argc, char **argv)
 		ns = NULL;
 	}
 
+	/* Open text file as mail message */
 	mail_raw_init(user);
 	mailr = mail_raw_open(mfd);
 
diff --git a/src/sieve-bin/sieve-test.c b/src/sieve-bin/sieve-test.c
index 7af2d36bd448f1c593df4976d4d9c03d8a93dc1b..f6656d1682bc2279fbe319369b81463c3a77ec3d 100644
--- a/src/sieve-bin/sieve-test.c
+++ b/src/sieve-bin/sieve-test.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
 
 #include "lib.h"
 #include "ostream.h"
@@ -16,9 +17,17 @@
 #include <fcntl.h>
 #include <pwd.h>
 
+/* 
+ * Configuration
+ */
+
 #define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail"
 #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON"
 
+/*
+ * Print help
+ */
+
 static void print_help(void)
 {
 #ifdef SIEVE_RUNTIME_TRACE
@@ -33,6 +42,10 @@ static void print_help(void)
 	);
 }
 
+/*
+ * Tool implementation
+ */
+
 int main(int argc, char **argv) 
 {
 	const char *scriptfile, *recipient, *sender, *mailbox, *dumpfile, *mailfile; 
diff --git a/src/sieve-bin/sievec.c b/src/sieve-bin/sievec.c
index adae1655405873216c2897f1400000191c94c244..66d7cd51c120ad9bd7923b22eb5d8914b77b1113 100644
--- a/src/sieve-bin/sievec.c
+++ b/src/sieve-bin/sievec.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -13,6 +14,9 @@
 
 #include "bin-common.h"
 
+/*
+ * Print help
+ */
 static void print_help(void)
 {
 	printf(
@@ -20,6 +24,10 @@ static void print_help(void)
 	);
 }
 
+/* 
+ * Tool implementation
+ */
+
 int main(int argc, char **argv) {
 	int i;
 	struct sieve_binary *sbin;
diff --git a/src/sieve-bin/sieved.c b/src/sieve-bin/sieved.c
index 12e5f31774d5ae561147ba7f41f7d969ef8853fd..ab6458cf3fc1aef0a32371a7d06aad09197caf06 100644
--- a/src/sieve-bin/sieved.c
+++ b/src/sieve-bin/sieved.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -14,6 +15,10 @@
 
 #include "bin-common.h"
 
+/*
+ * Print help
+ */
+
 static void print_help(void)
 {
 	printf(
@@ -21,6 +26,10 @@ static void print_help(void)
 	);
 }
 
+/*
+ * Tool implementation
+ */
+
 int main(int argc, char **argv) {
 	int i;
 	struct sieve_binary *sbin;