diff --git a/ws/Docbook/CustomLayer/slide/slideHdm.xsl b/ws/Docbook/CustomLayer/slide/slideHdm.xsl
index 1cb3ab718ab9aa5a4afdcf383c71f0ee0fdf3450..8877f8f603f0d95d8be47a05b5d99701784bca0b 100644
--- a/ws/Docbook/CustomLayer/slide/slideHdm.xsl
+++ b/ws/Docbook/CustomLayer/slide/slideHdm.xsl
@@ -1,76 +1,183 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
-    xmlns:xlink="http://www.w3.org/1999/xlink"  xmlns:d="http://docbook.org/ns/docbook">
+  xmlns:xlink="http://www.w3.org/1999/xlink"  
+  xmlns:m="http://www.w3.org/1998/Math/MathML"
+  xmlns:d="http://docbook.org/ns/docbook">
+  
+  <xsl:import href="../../docbook-xsl/xhtml/chunk.xsl"/>
+  <xsl:import href="../../docbook-xsl/xhtml/highlight.xsl"/>
+  <xsl:import href="../../docbook-xsl/webhelp/xsl/webhelp-common.xsl"/>
+  <xsl:import href="../../docbook-xsl/webhelp/xsl/titlepage.templates.xsl"/>
+  
+  <xsl:import href="../Common/common.xsl"/>
+
+  <!-- avoid namespace prefix since some epub readers get confused. Credits to
+    http://stackoverflow.com/questions/16810039/how-to-remove-namespace-prefix-leaving-namespace-value-xslt
+  -->
+  <xsl:template match="m:math[not(@alttext)]" priority="2">
+    <xsl:element name="{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
+      <xsl:attribute name="alttext">math formula</xsl:attribute>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </xsl:element>
+  </xsl:template>
+  
+  <xsl:template match="m:*" priority="1">
+    <xsl:element name="{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </xsl:element>
+  </xsl:template>
+  
+  <xsl:template match="/">
+    <xsl:apply-templates select="//d:chapter[contains(@annotations, 'slide')]|
+      //d:section[contains(@annotations, 'slide')]"
+      mode='slideSet'/>
     
-    <xsl:import href="/usr/share/xmlmind/addon/config/docbook5/xsl/html/docbook.xsl" />
+    <xsl:apply-templates select="//d:chapter[descendant::*[contains(@annotations, 'slide')]]|
+      //d:section[descendant::*[contains(@annotations, 'slide')]]"
+      mode='selectedSlideSet'/>
+  </xsl:template>
+  
+  <xsl:template match="d:chapter | d:section" mode='selectedSlideSet'>
+    <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{@xml:id}.html" indent="no">
+      <xsl:message>
+        <xsl:text>Processing </xsl:text>
+        <xsl:value-of select="name(.)"/>
+        <xsl:text>, id=</xsl:text>
+        <xsl:value-of select="@xml:id"/>
+      </xsl:message>
+      
+      <html lang="en">
+        <head>
+          <title>
+            <xsl:value-of select="d:title"/>
+          </title>
+          <link href="mi.css" rel="stylesheet" />
+          <link href="reveal.js/css/reveal.css" rel="stylesheet" />
+          <link href="reveal.js/css/theme/solarized.css" id="theme" rel="stylesheet" />
+          
+          <!-- Code syntax highlighting -->
+          <link href="reveal.js/lib/css/zenburn.css" rel="stylesheet" />
+          
+        </head>
         
-    <xsl:template match="/">
-        <xsl:apply-templates select="//d:section[descendant-or-self::*[contains(@annotations, 'slide')]]" mode='slideSet'/>        
-    </xsl:template>
-    
+        <body>
+          <!-- Wrap the entire slide show in a div using the "reveal" class. -->
+          <div class="reveal">
+            <!-- Wrap all slides in a single "slides" class -->
+            <div class="slides">
+              <xsl:apply-templates select="descendant::*[contains(@annotations, 'slide')]" mode="slideDescendants"/>
+            </div>
+          </div>
+          
+          <script src="reveal.js/lib/js/head.min.js"></script>
+          <script src="reveal.js/js/reveal.js"></script>
+          <script>/*<![CDATA[*/
+            
+            Reveal.initialize({
+            controls: true,
+            progress: true,
+            history: true,
+            center: true,
+            
+            transition: 'slide', // none/fade/slide/convex/concave/zoom
+            
+            math: {
+            mathjax: 'https://prog.mi.hdm-stuttgart.de/mathjax/MathJax.js',
+            config: 'TeX-AMS-MML_HTMLorMML',  // See http://docs.mathjax.org/en/latest/config-files.html
+            },
+            // Optional reveal.js plugins
+            dependencies: [
+            { src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
+            { src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
+            { src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
+            { src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
+            { src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
+            { src: 'reveal.js/plugin/notes/notes.js', async: true },
+            { src: 'reveal.js/plugin/math/math.js', async: true }
+            ]
+            });
+            /*]]>*/</script>
+        </body>
+      </html>
+    </xsl:result-document>
+  </xsl:template>
+  
   <xsl:template match="d:chapter | d:section" mode='slideSet'>
-        <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{@xml:id}.html" indent="no">
-            <html lang="en">
-                <head>
-                    <title>
-                        <xsl:value-of select="d:title"/>
-                    </title>
-                    <link href="mi.css" rel="stylesheet" />
-                    <link href="reveal.js/css/reveal.css" rel="stylesheet" />
-                    <link href="reveal.js/css/theme/solarized.css" id="theme" rel="stylesheet" />
-                    
-                    <!-- Code syntax highlighting -->
-                    <link href="reveal.js/lib/css/zenburn.css" rel="stylesheet" />
-                    
-                </head>
-                
-                <body>
-                    <!-- Wrap the entire slide show in a div using the "reveal" class. -->
-                    <div class="reveal">
-                        <!-- Wrap all slides in a single "slides" class -->
-                        <div class="slides">
-                          <xsl:apply-templates select="descendant::d:chapter/*|descendant::d:section/*" mode="slideSection"/>
-                        </div>
-                    </div>
-                    
-                    <script src="reveal.js/lib/js/head.min.js"></script>
-                    <script src="reveal.js/js/reveal.js"></script>
-                    <script>/*<![CDATA[*/
-			
-			Reveal.initialize({
-			controls: true,
-			progress: true,
-			history: true,
-			center: true,
-			
-			transition: 'slide', // none/fade/slide/convex/concave/zoom
-			
-			math: {
-		        mathjax: 'https://prog.mi.hdm-stuttgart.de/mathjax/MathJax.js',
-		        config: 'TeX-AMS-MML_HTMLorMML',  // See http://docs.mathjax.org/en/latest/config-files.html
-		    },
-
+    <xsl:result-document method="xhtml" encoding="utf-8" href="Slides/{@xml:id}.html" indent="no">
+      <xsl:message>
+        <xsl:text>Processing </xsl:text>
+        <xsl:value-of select="name(.)"/>
+        <xsl:text>, id=</xsl:text>
+        <xsl:value-of select="@xml:id"/>
+      </xsl:message>
+      
+      <html lang="en">
+        <head>
+          <title>
+            <xsl:value-of select="d:title"/>
+          </title>
+          <link href="mi.css" rel="stylesheet" />
+          <link href="reveal.js/css/reveal.css" rel="stylesheet" />
+          <link href="reveal.js/css/theme/solarized.css" id="theme" rel="stylesheet" />
+          
+          <!-- Code syntax highlighting -->
+          <link href="reveal.js/lib/css/zenburn.css" rel="stylesheet" />
+          
+        </head>
+        
+        <body>
+          <!-- Wrap the entire slide show in a div using the "reveal" class. -->
+          <div class="reveal">
+            <!-- Wrap all slides in a single "slides" class -->
+            <div class="slides">
+              <xsl:apply-templates select="." mode="slideDescendants"/>
+            </div>
+          </div>
+          
+          <script src="reveal.js/lib/js/head.min.js"></script>
+          <script src="reveal.js/js/reveal.js"></script>
+          <script>/*<![CDATA[*/
+            
+            Reveal.initialize({
+            controls: true,
+            progress: true,
+            history: true,
+            center: true,
+            
+            transition: 'slide', // none/fade/slide/convex/concave/zoom
+            
+            math: {
+            mathjax: 'https://prog.mi.hdm-stuttgart.de/mathjax/MathJax.js',
+            config: 'TeX-AMS-MML_HTMLorMML',  // See http://docs.mathjax.org/en/latest/config-files.html
+            },
             // Optional reveal.js plugins
-			dependencies: [
-			{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
-			{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
-			{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
-			{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
-			{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
-			{ src: 'reveal.js/plugin/notes/notes.js', async: true },
+            dependencies: [
+            { src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
+            { src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
+            { src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
+            { src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
+            { src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
+            { src: 'reveal.js/plugin/notes/notes.js', async: true },
             { src: 'reveal.js/plugin/math/math.js', async: true }
-			]
-			});
-			/*]]>*/</script>
-                </body>
-            </html>
-        </xsl:result-document>
-    </xsl:template>
+            ]
+            });
+            /*]]>*/</script>
+        </body>
+      </html>
+    </xsl:result-document>
+  </xsl:template>
   
-  <xsl:template match="d:title" mode="slideSection"/>
+  <xsl:template match="d:chapter|d:section" mode="slideDescendants">
+    <xsl:apply-templates select="*"  mode="slideDescendants"/>
+  </xsl:template>
   
-  <xsl:template match="*" mode="slideSection">
-    <section id="{@xml:id}">
+  <xsl:template match="d:title" mode="slideDescendants"/>
+  
+  <xsl:template match="*" mode="slideDescendants">
+    <xsl:message>AAAAAAAAAAAAA <xsl:value-of select="name(.)"/></xsl:message>
+    <section>
       <xsl:attribute name="xml:id">
         <xsl:choose>
           <xsl:when test="@xml:id"><xsl:value-of select="@xml:id"/></xsl:when>
@@ -81,49 +188,49 @@
     </section>
   </xsl:template>
   
-    
-<!--    <xsl:template match="d:section">
-        <xsl:param name="titleset"/>
-        <xsl:variable name="extendedTitleset" select="$titleset|d:title"/>
-        <section id="{@xml:id}">
-            <xsl:call-template name="titleNavigation">
-                <xsl:with-param name="titleset" select="$extendedTitleset"/>
-            </xsl:call-template>
-            <xsl:apply-templates select="*[not(self::d:section | self::d:title)]"/>
-        </section>
-        <xsl:apply-templates select="d:section">
-            <xsl:with-param name="titleset" select="$extendedTitleset"/>
-        </xsl:apply-templates>
+  
+  <!--    <xsl:template match="d:section">
+    <xsl:param name="titleset"/>
+    <xsl:variable name="extendedTitleset" select="$titleset|d:title"/>
+    <section id="{@xml:id}">
+    <xsl:call-template name="titleNavigation">
+    <xsl:with-param name="titleset" select="$extendedTitleset"/>
+    </xsl:call-template>
+    <xsl:apply-templates select="*[not(self::d:section | self::d:title)]"/>
+    </section>
+    <xsl:apply-templates select="d:section">
+    <xsl:with-param name="titleset" select="$extendedTitleset"/>
+    </xsl:apply-templates>
     </xsl:template>
     
     <xsl:template name="titleNavigation">
-        <xsl:param name="titleset"/>
-        <h4>
-            <xsl:for-each select="$titleset[1]">
-                <a href="#{parent::*/@xml:id}">
-                    <!-\- <xsl:value-of select="."/> -\->
-                    <xsl:text>Top</xsl:text><!-\- Overall title is likely too long -\->
-                </a>
-            </xsl:for-each>
-
-            <xsl:for-each select="$titleset[1 &lt; position() and position() &lt; last()]">
-                <xsl:text> &gt; </xsl:text>
-                <a href="#{parent::*/@xml:id}">
-                    <xsl:value-of select="."/>
-                </a>
-            </xsl:for-each>
-
-            <xsl:for-each select="$titleset[1 &lt; position() and position() = last()]">
-                <xsl:text> &gt; </xsl:text>
-                <xsl:value-of select="."/>
-            </xsl:for-each>
-        </h4>
+    <xsl:param name="titleset"/>
+    <h4>
+    <xsl:for-each select="$titleset[1]">
+    <a href="#{parent::*/@xml:id}">
+    <!-\- <xsl:value-of select="."/> -\->
+    <xsl:text>Top</xsl:text><!-\- Overall title is likely too long -\->
+    </a>
+    </xsl:for-each>
+    
+    <xsl:for-each select="$titleset[1 &lt; position() and position() &lt; last()]">
+    <xsl:text> &gt; </xsl:text>
+    <a href="#{parent::*/@xml:id}">
+    <xsl:value-of select="."/>
+    </a>
+    </xsl:for-each>
+    
+    <xsl:for-each select="$titleset[1 &lt; position() and position() = last()]">
+    <xsl:text> &gt; </xsl:text>
+    <xsl:value-of select="."/>
+    </xsl:for-each>
+    </h4>
     </xsl:template>
     
     <xsl:template match="d:title">
-        <h4>
-            <xsl:value-of select="."/>
-        </h4>
+    <h4>
+    <xsl:value-of select="."/>
+    </h4>
     </xsl:template>
--->    
+  -->    
 </xsl:stylesheet>
diff --git a/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl b/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl
index 2f33aa93728be03367a9a491108193c888de8df3..3c1b24b32719aa902fcad0f923455fc95904afd8 100644
--- a/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl
+++ b/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl
@@ -12,8 +12,6 @@
   <xsl:import href="../../docbook-xsl/webhelp/xsl/webhelp-common.xsl"/>
   <xsl:import href="../../docbook-xsl/webhelp/xsl/titlepage.templates.xsl"/>
 
-  <!--
-    -->
   <xsl:include href="hdmextensions.xsl"/>
   
   
diff --git a/ws/Docbook/Extensions/Tdata/fig.xml b/ws/Docbook/Extensions/Tdata/fig.xml
index 34feeb6a82586ca1dabf727d74490f5ed4759e0f..3bb6d3d050b1ac661c355d5b94cdf800302ff48f 100644
--- a/ws/Docbook/Extensions/Tdata/fig.xml
+++ b/ws/Docbook/Extensions/Tdata/fig.xml
@@ -81,4 +81,10 @@
   <xi:include href="Components/exampleSlides.xml" xpointer="element(/1)"/>
 
   <xi:include href="Video/video.xml" xpointer="element(/1)"/>
+
+  <appendix>
+    <title>Ter</title>
+
+    <para/>
+  </appendix>
 </book>
diff --git a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
index 2955871b3f9a5a17e25a9420f3ecc0a59efaef87..de20ada8105cb82f9a269735ebad5df74c78347c 100644
--- a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
+++ b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
@@ -79,7 +79,7 @@
   
   
   <xsl:template match="db:chapter" mode="genQuandaset">
-    <chapter id="{@xml:id}_qanda">
+    <section xml:id="{@xml:id}_qanda">
       <title>
         <xsl:text>Exercises in </xsl:text>
         <emphasis>
@@ -91,11 +91,13 @@
       <itemizedlist>
         <xsl:for-each select="descendant::db:qandaset">
             <listitem>
-              <xref linkend="{@xml:id}"/>
+              <para>
+                <xref linkend="{@xml:id}"/>
+              </para>
             </listitem>
         </xsl:for-each>                    
       </itemizedlist>  
-    </chapter>
+    </section>
   </xsl:template>
   
   <xsl:template match="db:qandaset" mode="selectOwnOrInheritedTitle">