diff --git a/ChangeLog b/ChangeLog
index 1e348e053d4216cdec6dbf1d21c7ee583c2484e9_Q2hhbmdlTG9n..0ca1df07b15d53f718494b44e330c3e30e3f18e8_Q2hhbmdlTG9n 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Jan  8 19:55:18 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+	* libxslt/xslt.c : small cleanup
+	* configure.in libxslt/xsltconfig.h.in: add memory debug and
+	  mechanism for compile-time options
+
 Sun Jan  7 22:53:12 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* libxslt/xslt.[ch]: started parsing templates
diff --git a/configure.in b/configure.in
index 1e348e053d4216cdec6dbf1d21c7ee583c2484e9_Y29uZmlndXJlLmlu..0ca1df07b15d53f718494b44e330c3e30e3f18e8_Y29uZmlndXJlLmlu 100644
--- a/configure.in
+++ b/configure.in
@@ -8,6 +8,24 @@
 AM_MAINTAINER_MODE
 
 dnl
+dnl Debug for DV
+dnl
+if test "${LOGNAME}" = "veillard" ; then
+    if test "${with_mem_debug}" = "" ; then
+	with_mem_debug="yes"
+    fi
+    CFLAGS="-Wall -g -pedantic"
+fi
+AC_ARG_WITH(mem_debug, [  --with-mem-debug        Add the memory debugging module (off)])
+if test "$with_mem_debug" = "yes" ; then
+    echo Enabling memory debug support
+    WITH_MEM_DEBUG=1
+else    
+    WITH_MEM_DEBUG=0
+fi
+AC_SUBST(WITH_MEM_DEBUG)
+
+dnl
 dnl The following new parameters were added to offer
 dnl the ability to specify the location of the libxml
 dnl library during linking and compilation.
@@ -100,6 +118,7 @@
 AC_OUTPUT([
 Makefile
 libxslt/Makefile
+libxslt/xsltconfig.h
 tests/Makefile
 xslt-config
 ])
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index 1e348e053d4216cdec6dbf1d21c7ee583c2484e9_bGlieHNsdC94c2x0LmM=..0ca1df07b15d53f718494b44e330c3e30e3f18e8_bGlieHNsdC94c2x0LmM= 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -9,9 +9,11 @@
  * Daniel.Veillard@imag.fr
  */
 
+#include "xsltconfig.h"
+
 #include <string.h>
 
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <libxml/xmlerror.h>
@@ -12,11 +14,11 @@
 #include <string.h>
 
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <libxml/xmlerror.h>
-#include <libxslt/xslt.h>
-#include <libxslt/xsltInternals.h>
+#include "xslt.h"
+#include "xsltInternals.h"
 
 #define DEBUG_PARSING
 
@@ -123,7 +125,7 @@
 xsltFreeTemplateList(xsltTemplatePtr template) {
     xsltTemplatePtr cur;
 
-    while (template == NULL) {
+    while (template != NULL) {
 	cur = template;
 	template = template->next;
 	xsltFreeTemplate(cur);
@@ -202,4 +204,7 @@
      * Find and handle the params
      */
     while (cur != NULL) {
+	/*
+	 * Remove Blank nodes found at this level.
+	 */
 	if (IS_BLANK_NODE(cur)) {
@@ -205,2 +210,4 @@
 	if (IS_BLANK_NODE(cur)) {
+	    xmlNodePtr blank = cur;
+
             cur = cur->next;
@@ -206,3 +213,5 @@
             cur = cur->next;
+	    xmlUnlinkNode(blank);
+	    xmlFreeNode(blank);
 	    continue;
 	}
@@ -207,9 +216,20 @@
 	    continue;
 	}
-	if (!(IS_XSLT_ELEM(cur))) {
-#ifdef DEBUG_PARSING
-	    xsltGenericError(xsltGenericErrorContext,
-		    "xsltParseStylesheetTop : found foreign element %s\n",
-		    cur->name);
-#endif
+	if ((IS_XSLT_ELEM(cur)) && (xmlStrEqual(cur->name, "param"))) {
+	    TODO /* Handle param */
+	} else
+	    break;
+	cur = cur->next;
+    }
+
+    /*
+     * Browse the remaining of the template
+     */
+    while (cur != NULL) {
+	/*
+	 * Remove Blank nodes found at this level.
+	 */
+	if (IS_BLANK_NODE(cur)) {
+	    xmlNodePtr blank = cur;
+
             cur = cur->next;
@@ -215,3 +235,5 @@
             cur = cur->next;
+	    xmlUnlinkNode(blank);
+	    xmlFreeNode(blank);
 	    continue;
 	}
@@ -216,7 +238,14 @@
 	    continue;
 	}
-	if (xmlStrEqual(cur->name, "param")) {
-	    TODO /* Handle param */
+	if ((IS_XSLT_ELEM(cur)) && (xmlStrEqual(cur->name, "param"))) {
+	    xmlNodePtr param = cur;
+
+            cur = cur->next;
+	    xsltGenericError(xsltGenericErrorContext,
+		"xsltParseStylesheetTop: ignoring misplaced param element\n");
+	    xmlUnlinkNode(param);
+	    xmlFreeNode(param);
+	    continue;
 	} else
 	    break;
 	cur = cur->next;
diff --git a/libxslt/xsltconfig.h.in b/libxslt/xsltconfig.h.in
new file mode 100644
index 0000000000000000000000000000000000000000..0ca1df07b15d53f718494b44e330c3e30e3f18e8_bGlieHNsdC94c2x0Y29uZmlnLmguaW4=
--- /dev/null
+++ b/libxslt/xsltconfig.h.in
@@ -0,0 +1,27 @@
+/*
+ * xsltconfig.h: compile-time version informations for the XSLT engine
+ *
+ * See Copyright for the status of this software.
+ *
+ * Daniel.Veillard@w3.org
+ */
+
+#ifndef __XML_XSLTCONFIG_H__
+#define __XML_XSLTCONFIG_H__
+
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if @WITH_MEM_DEBUG@
+#define DEBUG_MEMORY
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_XSLTCONFIG_H__ */