diff --git a/ChangeLog b/ChangeLog
index bcbe8552f3e0c8485cad758f71c82c187bbd3eba..11cb893f115bd5e52d901f3eefbc59990af8c354 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,90 @@
+1999-01-14  David Byers  <davby@ida.liu.se>
+
+	* src/server/session.c (who_is_on): Changed for loops to while
+	loops to deal with new semantics of session 0 and to make the code 
+	clearer. (who_is_on_ident): Ditto. (who_is_on_dynamic): Ditto.
+	(who_is_on_old): Ditto.
+
+	* src/server/internal-connections.c (get_conn_by_number): Always
+ 	interpred session 0 as the current session. 
+	(traverse_connections): Explicit check for session_no == 0 since
+ 	change in get_conn_by_number.
+
+	* src/server/session.c (disconnect): disconnect(0) disconnects the 
+	current session
+
+	Did some work on mail import and export (that jsk should have
+	taken care of. Grrrr....)
+	* doc/Protocol-A.texi (Predefined Aux-Item Types): Rewrote
+	documentation for mail import and export aux-items. Wrote a
+	chapter on mail import and export.
+
+	* run-support/aux-items.conf: Added aux-items for mail import and
+	export. 
+
+	* doc/Protocol-A.texi: Removed all @codes surrounding
+	cross-references since texinfo chokes on them.
+
+	* doc/hacking.texi (Notes for fncdef.txt): Added notes on
+	fncdef.txt.
+
+1999-01-13  David Byers  <davby@ida.liu.se>
+
+	Handle #ifdef/#endif and empty lines in fncdef.txt
+	* src/server/fncdef.txt: Added debug_info. This call does NOTHING
+	at the moment. It is just a proof of concept. It will do stuff
+	later.
+
+	* src/server/prot-a-parse-arg-h.awk: Handle #ifdef and #endif and
+	empty lines.
+
+	* src/server/fnc-def-init.awk: Ditto.
+
+	* src/server/prot-a-is-legal-fnc.awk: Ditto.
+
+	* src/server/call-switch.awk: Ditto.
+
+	* src/server/prot-a-parse-arg-c.awk: Ditto.
+
+	* src/server/com-h.awk: Ditto.
+
+	* acconfig.h: Added DEBUG_CALLS
+
+	* configure.in: Added option --with-efence to link with efence.
+	Added option --with-debug-calls to define DEBUG_CALLS when
+	compiling.
+
+	Arranged things so we have to put a call number into the
+	fncdef.txt file. This makes call numbers more explicit. It is also 
+	possible to have non-contiguous call numbers.
+	* src/server/prot-a.c (prot_a_parse_packet): Use function_index
+	field of connection to access parsers etc.
+
+	* src/server/connections.c: Added num_fnc_defs
+
+	* src/server/prot-a-parse-arg-h.awk: Updated for new format.
+
+	* src/server/connections.c (dump_statistics): Changed the format
+	of the statistics file to output function number before the call
+	number.
+
+	* src/server/connections.h: New field function_index
+	Added function field to Fnc_descriptor.
+
+	* src/server/call-switch.awk: Updated for new format in fncdef.txt 
+
+	* src/server/com-h.awk: Updated for new format in fncdef.txt
+
+	* src/server/prot-a-parse-arg-c.awk: Updated for new format in
+	fncdef.txt.
+
+	* src/server/prot-a.c (prot_a_is_legal_fnc): Removed hard-coded
+	switch and replaced it with include of prot-a-is-legal-fnc.incl
+
+	* src/server/prot-a-is-legal-fnc.awk: New function.
+
+	* src/server/Makefile.am: Add rules for prot-a-is-legal-fnc.incl
+
 1999-01-12  David Byers  <davby@ida.liu.se>
 
 	* src/server/testsuite/lyskomd.0/03.exp: Updated membership tests.
diff --git a/TODO b/TODO
index 7fd0711505605f097c13772e30bec4f97c8c6f1e..30a9a63ef148ceda85167f23f548fca1dad7f546 100644
--- a/TODO
+++ b/TODO
@@ -4,27 +4,48 @@ server.
 Before the next release
 =======================
 
+In progress 
+
+* Test the interpretation of session 0 as the current session.
+
+* Document aux-items for mail import/export. (3229403)
+
+* Fix aux-item 13, 14 and 15 according to 3228006 and 3228045.
+
+* Check that Async 13 is sent at the proper times (see 79208).
+
+
 These are show-stoppers that prevent a new release.
 
+* We have to be able to limit creation of certain aux-items to users
+  with special privileges. Most of the import/export items need this. 
+  Put in a new flag in the aux-item-definition file, add it to the
+  parser, check it in aux_item_check_add_perm or whatever the hell the
+  function was named. Test it. The biggest problem is to figure out
+  what permissions should be needed. I suppose it's possible that we
+  could let the user specify level and bits in the aux-items.conf
+  file, but that would mean mucking more with the parser.
+
+* Test validation of regexps containing groups. Try "X\\(YZ\\)?X".
+
+* Check change-what-am-i-doing very carefully.  According to 915974
+  and 916257 there may be a bug in it, but that is pure speculation.
+
 * There's a long-standing memory leak, probably in ISC. It appears to
   happen when we queue up lots of junk to clients that have died.
-  Trace what happens if we do isc_oflush and hit the E2BIG bit.
+  Trace what happens if we do isc_oflush and hit the E2BIG bit. This
+  may be related to the previous item.
 
 * Newline terminates requests.  Check that a wording similar to that
   in 1509862 is present in Protocol-A.texi.
 
+     Fixed, I think. Haven't checked the text mentioned though.
+
 * An asynchronous message is sent to everybody when a secret
   conference changes its name.  That is an unacceptable leak of
   sensitive information. (990788, 2804846)
 
-* Check change-what-am-i-doing very carefully.  According to 915974
-  and 916257 there may be a bug in it, but that is pure speculation.
-
-* disconnect(0) should disconnect the current session. (806239)
-
-* Remove the man pages for lyskomd.
-
-* Add the dbck reference to the lyskomd manual. Remove the man pages.
+* Remove the man pages for lyskomd and dbck.
 
 * Should the conference supervisor be able to set the secret bit of a
   membership type? Probably yes. Maybe no.
@@ -65,14 +86,8 @@ These are show-stoppers that prevent a new release.
 
 * Update/rewrite README.
 
-* Fix aux-item 13, 14 and 15 according to 3228006 and 3228045.
-
 * Fix the node structure of Protocol-A.texi (3228867).
 
-* Document aux-items for mail import/export. (3229403)
-
-* Check that Async 13 is sent at the proper times (see 79208).
-
 * Integrate doc/Bugrapporter into this document.
 
 * The protocol revision section of Protocol-A.info is incomplete.
@@ -356,3 +371,10 @@ Fixed
 
   No, and we don't any more.
 
+* disconnect(0) should disconnect the current session. (806239)
+
+     DONE. Session 0 is now always interpreted as the current session.
+
+* Add the dbck reference to the lyskomd manual. Remove the man pages.
+
+     DONE. There is now a dbck Texinfo manual
diff --git a/acconfig.h b/acconfig.h
index dbf5d184a321a23ca980ccfbfbe6b56816818dd4..bf5163a9e44c09f80a8a0d652c398b15ca4a97f5 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,5 +1,5 @@
 /*
- * $Id: acconfig.h,v 1.1 1998/12/29 13:42:25 byers Exp $
+ * $Id: acconfig.h,v 1.2 1999/01/14 11:49:07 byers Exp $
  * Copyright (C) 1998  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -24,6 +24,10 @@
  */
 
 
+/* Define if you want to define special debugging calls.
+   If you don't know if you need this, you don't. */
+#undef DEBUG_CALLS
+
 /* Define if your OS has buggy inet_ntoa. 
    If you don't know, define this */
 #define BUGGY_INET_NTOA
diff --git a/configure.in b/configure.in
index d544bfb48f06878e66d01971417f4854f2257a3f..14d9de886dd980f0a27d763de8fcc009ea11edeb 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.51 1998/12/26 22:40:10 byers Exp $
+dnl $Id: configure.in,v 1.52 1999/01/14 11:49:07 byers Exp $
 dnl Configuration for LysKOM
 dnl Copyright (C) 1993, 1994, 1995, 1996  Lysator Academic Computer Association.
 dnl
@@ -18,12 +18,22 @@ dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 dnl
 dnl Please mail bug reports to bug-lyskom@lysator.liu.se. 
 dnl
-AC_REVISION($Revision: 1.51 $)
+AC_REVISION($Revision: 1.52 $)
 AC_INIT(src/server/lyskomd.h)
 AM_CONFIG_HEADER(config.h)
 AC_CONFIG_AUX_DIR(scripts)
 AM_INIT_AUTOMAKE(lyskom-server, 2.0.0.pcl.2)
 
+AC_ARG_WITH([debug-calls],
+        [  --with-debug-calls         compile debug protocol requests],
+        [use_debug_calls=$withval],
+        [use_debug_calls=no])
+
+AC_ARG_WITH([efence],
+        [  --with-efence              link with ElectricFence],
+        [use_efence=$withval],
+        [use_efence=no])
+
 AC_ARG_WITH([purify],
 	[  --with-purify           link with Purify],
 	[use_purify=$withval],
@@ -53,6 +63,18 @@ AC_SUBST(PURIFY)
 then
 	PURIFY=purify
 fi]
+
+[if test "$use_efence" = "yes"
+then]
+        AC_CHECK_LIB(efence,malloc)
+[fi]
+
+AC_SUBST(DEBUG_CALLS)
+[if test "$use_debug_calls" = "yes"
+then]
+        AC_DEFINE(DEBUG_CALLS)
+[fi]
+
 # Do this test early since it may define _POSIX_SOURCE, which may
 # affect future tests.
 # FIXME: is this needed, now that we use AM_C_PROTOTYPES?
diff --git a/run-support/aux-items.conf b/run-support/aux-items.conf
index 29c3bed99eb25eba37950316ada166e25c975888..00117e47d259da443bd4d51a9c60975d99fd1c1b 100644
--- a/run-support/aux-items.conf
+++ b/run-support/aux-items.conf
@@ -1,5 +1,5 @@
 # 
-# $Id: aux-items.conf,v 1.5 1998/12/26 22:40:17 byers Exp $
+# $Id: aux-items.conf,v 1.6 1999/01/14 11:49:08 byers Exp $
 # Copyright (C) 1994, 1995, 1996  Lysator Academic Computer Association.
 # 
 # This file is part of the LysKOM server.
@@ -243,6 +243,124 @@
     inherit         = false;
 }
 
+#
+# Name of actual author. This should require some special privileges.
+#
+
+16 : mx-author (text)
+{
+    author-only     = true;
+    unique          = true;
+}
+
+#
+# From header of an imported e-mail
+#
+
+17 : mx-from (text)
+{
+    author-only     = true;
+    unique          = false;
+}
+
+#
+# Reply-To header of an imported e-mail
+#
+
+18 : mx-reply-to (text)
+{
+    author-only     = true;
+    unique          = false;
+}
+
+#
+# To header of an imported or to-be-exported e-mail
+#
+
+19 : mx-to (text)
+{
+    author-only     = false;
+    unique          = false;
+    hide-creator    = false;
+    secret          = false;
+}
+
+#
+# CC header of an imported or to-be-exported e-mail
+#
+
+20 : mx-cc (text)
+{
+    author-only     = false;
+    unique          = false;
+    hide-creator    = false;
+    secret          = false;
+}
+
+#
+# Date header of an imported e-mail
+#
+
+21 : mx-date (text)
+{
+    author-only     = true;
+    unique          = true;
+    inherit         = false;
+    validate        = "[0-9][0-9][0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\( [-+][0-9][0-9][0-9][0-9]\\)?";
+}
+
+#
+# Message-ID header of an imported e-mail
+#
+
+22 : mx-message-id (text)
+{
+    author-only     = true;
+    unique          = true;
+}
+
+#
+# In-Reply-To header of an imported e-mail
+#
+
+23 : mx-in-reply-to (text)
+{
+    author-only     = true;
+    unique          = false;
+}
+
+#
+# All mail headers
+#
+
+24 : mx-misc (text)
+{
+    author-only     = true;
+    unique          = true;
+}
+
+#
+# Mail filtering or something like that
+# Nobody quite knows how this will be used, so DON'T!
+#
+
+25 : mx-allow-filter (conference, letterbox) disabled
+{
+    author-only     = true;
+    unique          = false;
+}
+
+#
+# Mail rejection 
+# Nobody quite knows how this will be used, so DON'T!
+#
+
+26 : mx-reject-forward (conference, letterbox) disabled
+{
+    author-only     = true;
+    unique          = false;
+}
+
 #
 # Notify user about comments to text
 #
diff --git a/src/include/services.h b/src/include/services.h
index a9a466cecfc1d78d8f78632173004443c563393e..fe536ab59263dff129b341a45cd244e42bacd7d0 100644
--- a/src/include/services.h
+++ b/src/include/services.h
@@ -1,5 +1,5 @@
 /*
- * $Id: services.h,v 0.39 1999/01/13 12:08:22 byers Exp $
+ * $Id: services.h,v 0.40 1999/01/14 11:49:09 byers Exp $
  * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -716,6 +716,10 @@ extern Success
 KOM_( query_predefined_aux_items(Number_list *result));
 
 
+extern unsigned long
+KOM_ ( debug_info(void));
+
+
 /*
  * Asynchronous messages.
  */