From c087b683dc65ab8ac92819a1de681023331fe1ab Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Mon, 25 Jun 2012 14:10:00 +0200
Subject: beta 2012.06.25 14:10

---
 tex/context/base/anch-bar.mkiv                     | 150 ++--
 tex/context/base/anch-bck.mkvi                     |   2 +-
 tex/context/base/anch-pgr.mkiv                     | 107 +--
 tex/context/base/anch-tab.mkiv                     |   4 +-
 tex/context/base/bibl-tra.mkiv                     |   2 -
 tex/context/base/cont-new.mkii                     |   2 +-
 tex/context/base/cont-new.mkiv                     |   2 +-
 tex/context/base/context-version.pdf               | Bin 4145 -> 4144 bytes
 tex/context/base/context-version.png               | Bin 105884 -> 105508 bytes
 tex/context/base/context.mkii                      |   2 +-
 tex/context/base/context.mkiv                      |  13 +-
 tex/context/base/font-gds.mkiv                     |  83 ---
 tex/context/base/font-gds.mkvi                     |  83 +++
 tex/context/base/font-pre.mkiv                     |  16 +
 tex/context/base/font-sol.mkiv                     | 123 ----
 tex/context/base/font-sol.mkvi                     | 123 ++++
 tex/context/base/grph-fig.mkiv                     | 727 +++++++------------
 tex/context/base/grph-inc.mkiv                     | 805 +++++++++++++--------
 tex/context/base/l-number.lua                      |   4 +-
 tex/context/base/m-database.mkiv                   |   5 -
 tex/context/base/m-spreadsheet.mkiv                |   3 -
 tex/context/base/math-ini.mkiv                     |   8 -
 tex/context/base/mult-aux.mkiv                     |   8 +-
 tex/context/base/mult-chk.mkiv                     |  10 +-
 tex/context/base/mult-def.mkiv                     |  55 +-
 tex/context/base/mult-low.lua                      |   4 +-
 tex/context/base/mult-sys.mkiv                     |   3 -
 tex/context/base/node-aux.lua                      |   6 +-
 tex/context/base/node-fin.lua                      | 545 +++++++++-----
 tex/context/base/node-ini.lua                      |  42 +-
 tex/context/base/node-res.lua                      |  10 +
 tex/context/base/node-rul.mkiv                     |   3 -
 tex/context/base/node-tra.lua                      |  56 ++
 tex/context/base/node-typ.lua                      |   5 +
 tex/context/base/pack-mrl.mkiv                     |  78 +-
 tex/context/base/page-ini.mkiv                     |   1 -
 tex/context/base/spac-hor.mkiv                     |  14 +-
 tex/context/base/status-files.pdf                  | Bin 24487 -> 24520 bytes
 tex/context/base/status-lua.pdf                    | Bin 182309 -> 182496 bytes
 tex/context/base/status-mkiv.lua                   |  54 +-
 tex/context/base/status-mkiv.tex                   |   4 +-
 tex/context/base/strc-con.mkvi                     |   2 -
 tex/context/base/strc-doc.mkiv                     |   2 -
 tex/context/base/strc-flt.mkvi                     |   1 -
 tex/context/base/strc-lst.mkvi                     |   6 -
 tex/context/base/strc-not.mkvi                     |   4 -
 tex/context/base/syst-ini.mkiv                     |  11 +
 tex/context/base/task-ini.lua                      |   3 +
 tex/context/base/trac-vis.lua                      | 585 +++++++++++++++
 tex/context/base/trac-vis.mkiv                     | 111 +++
 tex/context/base/typo-krn.mkiv                     |   2 +-
 tex/generic/context/luatex/luatex-fonts-merged.lua |   2 +-
 52 files changed, 2484 insertions(+), 1407 deletions(-)
 delete mode 100644 tex/context/base/font-gds.mkiv
 create mode 100644 tex/context/base/font-gds.mkvi
 delete mode 100644 tex/context/base/font-sol.mkiv
 create mode 100644 tex/context/base/font-sol.mkvi
 create mode 100644 tex/context/base/trac-vis.lua
 create mode 100644 tex/context/base/trac-vis.mkiv

(limited to 'tex')

diff --git a/tex/context/base/anch-bar.mkiv b/tex/context/base/anch-bar.mkiv
index 9f9770fb6..c7c6190be 100644
--- a/tex/context/base/anch-bar.mkiv
+++ b/tex/context/base/anch-bar.mkiv
@@ -58,7 +58,9 @@
 \installcommandhandler \??sidebar {sidebar} \??sidebar
 
 \newcount\c_anch_sidebars_n
-\newdimen\c_anch_sidebars_distance
+\newcount\c_anch_sidebars_current % local
+\newdimen\d_anch_sidebars_distance
+\newcount\c_anch_sidebars_level
 
 % \setupMPvariables
 %   [mpos:sidebar]
@@ -67,24 +69,60 @@
 %    distance=5pt]
 
 \setupsidebar
-  [\c!rulethickness=2pt,
+  [\c!rulethickness=\dimexpr\bodyfontsize/6\relax, % 2pt default
    \c!rulecolor=\s!black,
    \c!alternative=0,
-   \c!topoffset=0pt,
-   \c!bottomoffset=0pt,
-   \c!distance=.5\bodyfontsize]
+   \c!topoffset=\zeropoint,
+   \c!bottomoffset=\zeropoint,
+   \c!distance=.5\bodyfontsize,
+   \c!level=,
+   \c!leftmargindistance=\zeropoint]
 
 \let\setupsidebars\setupsidebar
 
 \unexpanded\def\startsidebar
   {\dosingleempty\anch_sidebars_start}
 
-\def\anch_sidebars_start[#1]%
+\unexpanded\def\startsidebar
+  {\dodoubleempty\anch_sidebars_start}
+
+\def\anch_sidebars_start[#1][#2]%
   {\bgroup
-   \def\currentsidebar{#1}%
    \dontleavehmode
+   \advance\c_anch_sidebars_level\plusone
    \global\advance\c_anch_sidebars_n\plusone
-   \advance\c_anch_sidebars_distance\sidebarparameter\c!distance
+   \c_anch_sidebars_current\c_anch_sidebars_n\relax % relax needed
+   \doifassignmentelse{#1}
+     {\edef\currentsidebar{\the\c_anch_sidebars_level}%
+      \checksidebarparent
+      \setupcurrentsidebar[#1]}
+     {\def\currentsidebar{#1}%
+      \setupcurrentsidebar[#2]}%
+   \scratchdistance\sidebarparameter\c!distance\relax
+   \edef\m_level{\sidebarparameter\c!level}%
+   \ifx\m_level\empty
+     \ifnum\c_anch_sidebars_level=\plusone
+       \scratchdimen\sidebarparameter\c!leftmargindistance\relax
+       \ifdim\scratchdimen=\zeropoint
+         \advance\d_anch_sidebars_distance\scratchdistance\relax
+       \else
+         \d_anch_sidebars_distance\scratchdimen
+       \fi
+     \else
+       \advance\d_anch_sidebars_distance\scratchdistance\relax
+     \fi
+   \else
+     \ifnum\m_level=\plusone
+       \scratchdimen\sidebarparameter\c!leftmargindistance\relax
+       \ifdim\scratchdimen=\zeropoint
+         \advance\d_anch_sidebars_distance\scratchdistance\relax
+       \else
+         \d_anch_sidebars_distance\scratchdimen
+       \fi
+     \else
+       \d_anch_sidebars_distance\dimexpr\scratchdimen+\numexpr\m_level-\plusone\relax\dimexpr\scratchdistance\relax\relax
+     \fi
+   \fi
    \startpositionoverlay{text-1}%
      \normalexpanded{\setMPpositiongraphicrange % maybe expand in definition
        {b:sidebar:\the\c_anch_sidebars_n}%
@@ -94,15 +132,17 @@
         linewidth=\sidebarparameter\c!rulethickness,
         linecolor=\sidebarparameter\c!rulecolor,
         alternative=\sidebarparameter\c!alternative,
-        topoffset=\sidebarparameter\c!topoffset,
-        bottomoffset=\sidebarparameter\c!bottomoffset,
-        distance=\the\c_anch_sidebars_distance}}%
+        topoffset=\the\dimexpr\sidebarparameter\c!topoffset,
+        bottomoffset=\the\dimexpr\sidebarparameter\c!bottomoffset,
+        distance=\the\d_anch_sidebars_distance}%
+     }%
    \stoppositionoverlay
-   \bpos{sidebar:\the\c_anch_sidebars_n}}
+   \bpos{sidebar:\the\c_anch_sidebars_current}%
+   \ignorespaces}
 
 \unexpanded\def\stopsidebar
   {\removelastspace
-   \epos{sidebar:\the\c_anch_sidebars_n}
+   \epos{sidebar:\the\c_anch_sidebars_current}
    \carryoverpar\egroup}
 
 %D Let's keep this nice and simple (okay, we could pass the 6 variables in
@@ -121,49 +161,73 @@
     \MPpositiongraphic{mpos:sidebar}{}%
 \stopMPpositionmethod
 
-%D We now reimplement the margin rules handler defined in
-%D \type {core-rul}:
+%D We now reimplement the \MKII\ margin rules handler in a more
+%D modern way.
 %D
-%D \setupmarginrules[level=5]
+%D \setupmarginrules
+%D   [rulecolor=darkred,
+%D    rulethickness=2pt]
 %D
-%D \startmarginrule[1]
-%D First we set the level at~5. Next we typeset this first
-%D paragraph as a level~1 one. As expected no rule show up.
-%D \stopmarginrule
+%D \setupmarginrules % sidebar
+%D   [2]
+%D   [rulecolor=darkblue]
 %D
-%D \startmarginrule[5]
-%D The second paragraph is a level~5 one. As we can see here,
-%D the marginal rule gets a width according to its level.
+%D \startmarginrule[1]
+%D     \input ward
+%D     \startmarginrule[2]
+%D         \input ward
+%D         \startmarginrule[3]
+%D             \input ward
+%D             \startmarginrule[level=6,rulecolor=darkgreen]
+%D                 \input ward
+%D             \stopmarginrule
+%D             \input ward
+%D         \stopmarginrule
+%D         \input ward
+%D     \stopmarginrule
+%D     \input ward
 %D \stopmarginrule
 %D
-%D \startmarginrule[8]
-%D It will of course be no surprise that this third paragraph
-%D has a even thicker margin rule. This behavior can be
-%D overruled by specifying the width explictly.
-%D \stopmarginrule
+%D Compared to the old mechanism we now can pass settings too.
 
 \definesidebar
   [\v!margin]
-  [\c!rulethickness=\@@karulethickness,
-   \c!distance=\dimexpr\leftmargindistance-\@@karulethickness/2\relax]
+  [\c!leftmargindistance=\dimexpr\leftmargindistance+\sidebarparameter\c!rulethickness/2\relax]
 
-\definecomplexorsimple\startmarginrule
+\dorecurse{5}{\definesidebar[\v!margin:#1][\v!margin]} % let's be nice and predefine 5 levels
 
-\def\simplestartmarginrule
-  {\complexstartmarginrule[1]}
+\unexpanded\def\setupmarginrule
+  {\dodoubleargument\anch_marginrules_setup}
 
-\def\complexstartmarginrule[#1]%
-  {\bgroup
-   \ifnum#1<\@@kalevel\relax
-     \let\stopmarginrule\egroup
+\def\anch_marginrules_setup[#1][#2]%
+  {\ifsecondargument
+     \setupsidebar[\v!margin:#1][#2]%
    \else
-     \def\@@kadefaultwidth{#1}%
-     \let\stopmarginrule\dostopmarginrule
-     \normalexpanded{\startsidebar[\v!margin]}% why expanded
+     \setupsidebar[\v!margin][#1]%
    \fi}
 
-\def\dostopmarginrule
-  {\stopsidebar
-   \egroup}
+\let\setupmarginrules\setupmarginrule
+
+\unexpanded\def\startmarginrule
+  {\dosingleempty\anch_marginrules_start}
+
+\unexpanded\def\startmarginrule
+  {\dosingleempty\anch_marginrules_start}
+
+\def\anch_marginrules_start[#1]% pretty inefficient checking
+  {\edef\m_anch_marginrules_kind{#1}%
+   \ifx\m_anch_marginrules_kind\empty
+     \anch_sidebars_start[\v!margin][]%
+   \else
+     \doifassignmentelse\m_anch_marginrules_kind
+       {\anch_sidebars_start[\v!margin][#1]}%
+       {\anch_marginrules_check{#1}%
+        \anch_sidebars_start[\v!margin:#1][\c!level=#1]}%
+   \fi}
+
+\def\anch_marginrules_check#1%
+  {\doifnotcommandhandler\??sidebar{\v!margin:#1}{\definesidebar[\v!margin:#1][\v!margin]}}
+
+\let\stopmarginrule\stopsidebar
 
 \protect \endinput
diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi
index 8f22d8a6d..79e42dc0a 100644
--- a/tex/context/base/anch-bck.mkvi
+++ b/tex/context/base/anch-bck.mkvi
@@ -298,7 +298,7 @@
    \endgraf % new
    \textbackgroundparameter\c!after}
 
-\unexpanded\def\checkpositionoverlays
+\unexpanded\def\checkpositionoverlays % overloads \relax in anch-pgr
   {\ifproductionrun
      \enabletextarearegistration
      \enablehiddenbackground
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 38e0ff0af..130116bc7 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -33,7 +33,7 @@
 \installcorenamespace{positionaction}
 \installcorenamespace{positioncleanup}
 
-\unexpanded\def\dosetpositionaction#1%
+\unexpanded\def\anch_positions_set_action#1%
   {\expandafter\gdef\csname\??positionaction#1\endcsname} % nicely gobbles spaces
 
 \unexpanded\def\doifpositionaction#1%
@@ -111,7 +111,7 @@
   {\begingroup
    \edef\currentpositionanchor
      {\ifx\currentpositionoverlay\empty#3\else\currentpositionoverlay::\MPanchoridentifier\fi}%
-   \normalexpanded{\dosetpositionaction{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}%
+   \normalexpanded{\anch_positions_set_action{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}%
    \let#1\relax
    \ifcsname\??positioncleanup\currentpositionanchor\endcsname
      \setxvalue{\??positioncleanup\currentpositionanchor}%
@@ -140,9 +140,6 @@
      \fi
    \fi\fi}
 
-% \def\anch_positions_register_page_indeed#1%
-%   {\setbox#1\hbox{\hpos\pageanchor{\box#1}}}
-
 \def\anch_positions_register_page_indeed#1% maybe like text
   {\ifvbox#1\setbox#1\hbox{\box#1}\fi
    \anch_make_page_box{#1}}
@@ -218,7 +215,6 @@
 %D \typebuffer[graphic]
 
 \def\MPanchoridentifier{mpa}  % {mp-anchor}
-%def\MPoverlayposprefix{MO::} % not used
 
 %D The rest of the definitions concerning such overlays may
 %D look complicated,
@@ -237,8 +233,8 @@
 \def\textbackgroundoverlay#1{\v!text#1}
 \def\MPanchornumber         {\the\realpageno}
 
-\def\positionoverlay  % the test prevents too many redundant positions
-  {\ifpositioning     % in (not used) text* position layers
+\unexpanded\def\positionoverlay % the test prevents too many redundant positions
+  {\ifpositioning               % in (not used) text* position layers
      \expandafter\anch_positions_overlay_indeed
    \else % also \iftrialtypesetting test here?
      \expandafter\gobbleoneargument
@@ -269,7 +265,7 @@
       \box\scratchbox
       \vfill}}
 
-\def\positionregionoverlay  % shares regions
+\unexpanded\def\positionregionoverlay  % shares regions
   {\ifpositioning
      \expandafter\anch_positions_region_overlay_indeed
    \else % also \iftrialtypesetting test here?
@@ -308,9 +304,15 @@
      \expandafter\anch_positions_overlay_start_yes
    \fi}
 
+\let\stoppositionoverlay\relax
+
 \def\anch_positions_overlay_start_nop#1\stoppositionoverlay
   {}
 
+\ifdefined\checkpositionoverlays \else \let\checkpositionoverlays\relax \fi
+
+\let\currentpositionoverlay\empty
+
 \def\anch_positions_overlay_start_yes#1%
   {\checkpositionoverlays
    \edef\currentpositionoverlay{#1}}
@@ -318,9 +320,11 @@
 \unexpanded\def\stoppositionoverlay
   {\let\currentpositionoverlay\empty}
 
+% needs checking if still needed
+%
 % \def\resetpositionoverlay#1%
-%   {\dosetpositionaction{#1::\MPanchoridentifier::}{}}
-
+%   {\anch_positions_set_action{#1::\MPanchoridentifier::}{}}
+%
 % \def\handlepositionboxes#1#2#3%
 %   {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}}
 %
@@ -332,15 +336,15 @@
 % \appendtoks
 %     \let\dohandlepositionboxes\doinsertpositionboxes % was handle ?
 % \to \everyinsertpositionaction
-
-\def\docleanpositionboxes#1#2#3% pos tag setups
-  {\ifnum\MPp{#1}<\realpageno \else
-     \noexpand \dohandlepositionboxes{#1}{#2}{#3}% reinsert
-   \fi}
-
-\appendtoks
-    \let\dohandlepositionboxes\docleanpositionboxes
-\to \everycleanpositionaction
+%
+% \def\docleanpositionboxes#1#2#3% pos tag setups
+%   {\ifnum\MPp{#1}<\realpageno \else
+%      \noexpand \dohandlepositionboxes{#1}{#2}{#3}% reinsert
+%    \fi}
+%
+% \appendtoks
+%     \let\dohandlepositionboxes\docleanpositionboxes
+% \to \everycleanpositionaction
 
 %D A position graphic is a normal (non||reused) \METAPOST\
 %D graphic, used immediately, with zero dimensions, so that a
@@ -350,7 +354,7 @@
 \installcorenamespace{positionmethod}
 %installcorenamespace{graphicvariable}
 
-\newbox\positiongraphicbox
+\newbox\b_anch_positions_graphic
 
 \def\startMPpositiongraphic % id setups
   {\dodoublegroupempty\anch_positions_meta_graphic_start}
@@ -375,7 +379,7 @@
    \startMPcode#3\stopMPcode
    \endgroup}
 
-\def\MPpositiongraphic
+\unexpanded\def\MPpositiongraphic
   {\dodoublegroupempty\anch_positions_meta_graphic_direct}
 
 \def\anch_positions_meta_graphic_direct#1% tag setups
@@ -402,9 +406,9 @@
    \anch_positions_meta_graphic_prepare
    \obeyMPboxorigin % do we also set the size ? when needed this must be done in mp ... might change
    \def\anch_positions_meta_graphic_direct{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments
-   \setbox\positiongraphicbox\hbox{\ignorespaces\csname#1#2\endcsname\removelastspace}%
-   \smashbox\positiongraphicbox
-   \box\positiongraphicbox
+   \setbox\b_anch_positions_graphic\hbox{\ignorespaces\csname#1#2\endcsname\removelastspace}%
+   \smashbox\b_anch_positions_graphic
+   \box\b_anch_positions_graphic
    \endgroup}
 
 \def\anch_positions_meta_graphic_nested#1#2#3% nesting used in prikkels / pascal (might go away)
@@ -422,73 +426,72 @@
 
 %D Simple one position graphics.
 
-\def\setMPpositiongraphic
-  {\dotriplegroupempty\dosetMPpositiongraphic}
+\unexpanded\def\setMPpositiongraphic
+  {\dotriplegroupempty\anch_positions_meta_graphic_set}
 
-\def\dosetMPpositiongraphic#1#2#3% pos tag vars
+\def\anch_positions_meta_graphic_set#1#2#3% pos tag vars
   {\ifx\currentpositionoverlay\empty
-     \dosetpositionaction{#1}{\MPpositiongraphic{#2}{#3}}%
+     \anch_positions_set_action{#1}{\MPpositiongraphic{#2}{#3}}%
    \else % silly can be one
-     \handlepositiongraphics{#1}{#2}{#3}%
+     \anch_positions_meta_graphic_handle{#1}{#2}{#3}%
    \fi}
 
-\def\handlepositiongraphics#1#2#3% combine with boxes
-  {\handlepositionaction\dohandleMPpositiongraphic\with{#1}{#2}{#3}\on{#2}}
+\def\anch_positions_meta_graphic_handle#1#2#3% combine with boxes
+  {\handlepositionaction\anch_positions_meta_graphic_handle_indeed\with{#1}{#2}{#3}\on{#2}}
 
-\def\doinsertMPpositiongraphic#1#2#3% pos tag setups
+\def\anch_positions_meta_graphic_insert#1#2#3% pos tag setups
   {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard
      \def\currentposition{#1}\MPpositiongraphic{#2}{#3}%
    \fi}
 
 \appendtoks
-    \let\dohandleMPpositiongraphic\doinsertMPpositiongraphic
+    \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_insert
 \to \everyinsertpositionaction
 
-\def\docleanMPpositiongraphic#1#2#3% pos tag setups
+\def\anch_positions_meta_graphic_cleanup#1#2#3% pos tag setups
   {\ifnum\MPp{#1}<\realpageno \else
-     \noexpand\dohandleMPpositiongraphic{#1}{#2}{#3}%
+     \noexpand\anch_positions_meta_graphic_handle_indeed{#1}{#2}{#3}%
    \fi}
 
 \appendtoks
-    \let\dohandleMPpositiongraphic\docleanMPpositiongraphic
+    \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_cleanup
 \to \everycleanpositionaction
 
 %D Graphics that span two positions (beware, does not cross pages).
 
 \unexpanded\def\setMPpositiongraphicrange
-  {\doquadruplegroupempty\dosetMPpositiongraphicrange}
+  {\doquadruplegroupempty\anch_positions_meta_graphic_set_range}
 
-\def\dosetMPpositiongraphicrange#1#2#3#4% bpos epos tag vars
+\def\anch_positions_meta_graphic_set_range#1#2#3#4% bpos epos tag vars
   {\ifx\currentpositionoverlay\empty
-     \dosetpositionaction{#1}{\MPpositiongraphic{#3}{#4}}%
+     \anch_positions_set_action{#1}{\MPpositiongraphic{#3}{#4}}%
    \else
-     \handlepositiongraphicsrange{#1}{#2}{#3}{#4}%
+     \anch_positions_meta_graphic_handle_range{#1}{#2}{#3}{#4}%
    \fi}
 
-\def\handlepositiongraphicsrange#1#2#3#4%
-  {\handlepositionaction\dohandleMPpositiongraphicrange\with{#1}{#2}{#3}{#4}\on{#2}}
+\def\anch_positions_meta_graphic_handle_range#1#2#3#4%
+  {\handlepositionaction\anch_positions_meta_graphic_handle_range_indeed\with{#1}{#2}{#3}{#4}\on{#2}}
 
-\def\doinsertMPpositiongraphicrange#1#2#3#4% pos pos tag setups
+\def\anch_positions_meta_graphic_insert_range#1#2#3#4% pos pos tag setups
   {\ctxcommand{doifelserangeonpage("#1","#2",\number\realpageno)}%
-     {%\writestatus{YES}{#1/#2 => #3}%
-      \def\currentposition{#1}%
+     {\def\currentposition{#1}%
       \MPpositiongraphic{#3}{#4}}%
-     {}}%\writestatus{NOP}{#1/#2 = #3}}}
+     {}}
 
 \appendtoks
-    \let\dohandleMPpositiongraphicrange\doinsertMPpositiongraphicrange
+    \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_insert_range
 \to \everyinsertpositionaction
 
-\def\docleanMPpositiongraphicrange#1#2#3#4% pos tag setups
+\def\anch_positions_meta_graphic_cleanup_range#1#2#3#4% pos tag setups
   {\ifnum\MPp{#2}<\realpageno \else
-     \noexpand \dohandleMPpositiongraphicrange{#1}{#2}{#3}{#4}%
+     \noexpand \anch_positions_meta_graphic_handle_range_indeed{#1}{#2}{#3}{#4}%
    \fi}
 
 \appendtoks
-    \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange
+    \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_cleanup_range
 \to \everycleanpositionaction
 
-\let\dohandleMPpositiongraphicrange\gobblefourarguments
+\let\anch_positions_meta_graphic_handle_range_indeed\gobblefourarguments
 
 % Helpers:
 
diff --git a/tex/context/base/anch-tab.mkiv b/tex/context/base/anch-tab.mkiv
index 4bdaa2ef9..1b90d2476 100644
--- a/tex/context/base/anch-tab.mkiv
+++ b/tex/context/base/anch-tab.mkiv
@@ -350,13 +350,13 @@
 \def\remappositionframed#1#2% from to
   {\copyposition{b:#1}{b:#2}%
    \copyposition{e:#1}{e:#2}%
-   \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}}
+   \anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}}
 
 \unexpanded\def\definepositionframed
   {\dodoubleargument\dodefinepositionframed}
 
 \def\dodefinepositionframed[#1][#2]%
-  {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}}
+  {\anch_positions_set_action{b:#1}{\dopositionframed[#1][#2]}}
 
 \unexpanded\def\positionframed
   {\bgroup
diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv
index 3531703ad..7cef23d88 100644
--- a/tex/context/base/bibl-tra.mkiv
+++ b/tex/context/base/bibl-tra.mkiv
@@ -1484,8 +1484,6 @@
 
 %D And some defaults are loaded from bibl-apa:
 
-\def\c!monthconversion{monthconversion} % todo
-
 \setuppublications
   [\c!monthconversion=,
    \c!alternative=apa,
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 52c3f024d..550e96d39 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2012.06.22 13:11}
+\newcontextversion{2012.06.25 14:10}
 
 %D This file is loaded at runtime, thereby providing an
 %D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index f902d6937..dfa96f3ec 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2012.06.22 13:11}
+\newcontextversion{2012.06.25 14:10}
 
 %D This file is loaded at runtime, thereby providing an
 %D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 1e567e2f1..f40eac204 100644
Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 742fef507..3c16bda9e 100644
Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 3fa3c60f7..a44f68a57 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2012.06.22 13:11}
+\edef\contextversion{2012.06.25 14:10}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 380a52d6d..b29e5511f 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -23,7 +23,7 @@
 %D up and the dependencies are more consistent.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2012.06.22 13:11}
+\edef\contextversion{2012.06.25 14:10}
 
 %D For those who want to use this:
 
@@ -107,9 +107,10 @@
 
 \loadmarkfile{mult-ini}
 \loadmarkfile{mult-sys}
+\loadmarkfile{mult-aux}
 \loadmarkfile{mult-def}
 \loadmarkfile{mult-chk}
-\loadmarkfile{mult-aux}
+%loadmarkfile{mult-aux} % moved up
 \loadmkvifile{mult-dim}
 
 \loadmarkfile{cldf-int} % interface
@@ -148,7 +149,7 @@
 
 \loadmarkfile{supp-box}
 
-\loadmarkfile{supp-vis}
+%loadmarkfile{supp-vis} % replaced by trac-vis
 \loadmarkfile{supp-fun} % close to obsolete
 
 \loadmarkfile{supp-ran}
@@ -347,7 +348,7 @@
 \loadmarkfile{font-tra}
 \loadmarkfile{font-uni}
 \loadmkvifile{font-col}
-\loadmarkfile{font-gds}
+\loadmkvifile{font-gds}
 
 \loadmarkfile{lxml-css}
 
@@ -355,6 +356,8 @@
 
 \loadmarkfile{blob-ini} % not to be used, we only use a helper
 
+\loadmarkfile{trac-vis}
+
 \loadmarkfile{typo-cln}
 \loadmarkfile{typo-spa}
 \loadmarkfile{typo-krn}
@@ -419,7 +422,7 @@
 
 \loadmarkfile{core-fnt}
 \loadmarkfile{node-rul}
-\loadmarkfile{font-sol} % font solutions
+\loadmkvifile{font-sol} % font solutions
 
 \loadmkvifile{strc-not}
 \loadmkvifile{strc-lnt}
diff --git a/tex/context/base/font-gds.mkiv b/tex/context/base/font-gds.mkiv
deleted file mode 100644
index 2305a0edd..000000000
--- a/tex/context/base/font-gds.mkiv
+++ /dev/null
@@ -1,83 +0,0 @@
-%D \module
-%D   [       file=font-gds,
-%D        version=2009.10.14,
-%D          title=\CONTEXT\ Font Support,
-%D       subtitle=Colorschemes,
-%D         author=Hans Hagen,
-%D           date=\currentdate,
-%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Font Support / Colorschemes}
-
-%registerctxluafile{font-gds}{1.001}
-
-\unprotect
-
-% this will become colorgroups and move to font-col or so
-
-\definecolor[colorscheme:1:1][s=.75]
-\definecolor[colorscheme:1:2][r=.75]
-\definecolor[colorscheme:1:3][g=.75]
-\definecolor[colorscheme:1:4][b=.75]
-\definecolor[colorscheme:1:5][c=.75]
-\definecolor[colorscheme:1:6][m=.75]
-\definecolor[colorscheme:1:7][y=.75]
-
-\definecolor[colorscheme:2:7][s=.75]
-\definecolor[colorscheme:2:6][r=.75]
-\definecolor[colorscheme:2:5][g=.75]
-\definecolor[colorscheme:2:4][b=.75]
-\definecolor[colorscheme:2:3][c=.75]
-\definecolor[colorscheme:2:2][m=.75]
-\definecolor[colorscheme:2:1][y=.75]
-
-\definesystemattribute[colorscheme][public]
-
-\unexpanded\def\loadfontgoodies[#1]%
-  {\ctxcommand{loadfontgoodies("#1")}}
-
-\unexpanded\def\setfontcolorscheme % will move to the lua end
-  {\ctxcommand{enablefontcolorschemes()}%
-   \unexpanded\xdef\setfontcolorscheme[##1]{\attribute\colorschemeattribute##1\relax}%
-   \setfontcolorscheme}
-
-\unexpanded\def\resetfontcolorscheme
-  {\attribute\colorschemeattribute\attributeunsetvalue}
-
-\protect \endinput
-
-% \definefontfeature[husayni-colored][goodies=husayni,colorscheme=default,featureset=default]
-%
-% \definedfont[husayni*husayni-colored at 36pt]
-%
-% \starttext \pardir TRT \textdir TRT
-%
-% \setfontcolorscheme[1]
-%
-% اَلْحَمْ‍دُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
-% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
-% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
-% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
-% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
-%
-% \setfontcolorscheme[2]
-%
-% اَلْحَمْ‍دُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
-% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
-% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
-% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
-% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
-%
-% \resetfontcolorscheme
-%
-% اَلْحَمْ‍دُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
-% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
-% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
-% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
-% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
-%
-% \stoptext
diff --git a/tex/context/base/font-gds.mkvi b/tex/context/base/font-gds.mkvi
new file mode 100644
index 000000000..d4760a470
--- /dev/null
+++ b/tex/context/base/font-gds.mkvi
@@ -0,0 +1,83 @@
+%D \module
+%D   [       file=font-gds,
+%D        version=2009.10.14,
+%D          title=\CONTEXT\ Font Support,
+%D       subtitle=Colorschemes,
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Font Support / Colorschemes}
+
+%registerctxluafile{font-gds}{1.001}
+
+\unprotect
+
+% this will become colorgroups and move to font-col or so
+
+\definecolor[colorscheme:1:1][s=.75]
+\definecolor[colorscheme:1:2][r=.75]
+\definecolor[colorscheme:1:3][g=.75]
+\definecolor[colorscheme:1:4][b=.75]
+\definecolor[colorscheme:1:5][c=.75]
+\definecolor[colorscheme:1:6][m=.75]
+\definecolor[colorscheme:1:7][y=.75]
+
+\definecolor[colorscheme:2:7][s=.75]
+\definecolor[colorscheme:2:6][r=.75]
+\definecolor[colorscheme:2:5][g=.75]
+\definecolor[colorscheme:2:4][b=.75]
+\definecolor[colorscheme:2:3][c=.75]
+\definecolor[colorscheme:2:2][m=.75]
+\definecolor[colorscheme:2:1][y=.75]
+
+\definesystemattribute[colorscheme][public]
+
+\unexpanded\def\loadfontgoodies[#filename]%
+  {\ctxcommand{loadfontgoodies("#filename")}}
+
+\unexpanded\def\setfontcolorscheme % will move to the lua end
+  {\ctxcommand{enablefontcolorschemes()}%
+   \unexpanded\xdef\setfontcolorscheme[##1]{\attribute\colorschemeattribute##1\relax}%
+   \setfontcolorscheme}
+
+\unexpanded\def\resetfontcolorscheme
+  {\attribute\colorschemeattribute\attributeunsetvalue}
+
+\protect \endinput
+
+% \definefontfeature[husayni-colored][goodies=husayni,colorscheme=default,featureset=default]
+%
+% \definedfont[husayni*husayni-colored at 36pt]
+%
+% \starttext \pardir TRT \textdir TRT
+%
+% \setfontcolorscheme[1]
+%
+% اَلْحَمْ‍دُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
+% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
+% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
+% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
+% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
+%
+% \setfontcolorscheme[2]
+%
+% اَلْحَمْ‍دُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
+% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
+% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
+% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
+% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
+%
+% \resetfontcolorscheme
+%
+% اَلْحَمْ‍دُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ
+% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛
+% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ،
+% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ
+% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ.
+%
+% \stoptext
diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv
index 141bfd2ff..e5999df14 100644
--- a/tex/context/base/font-pre.mkiv
+++ b/tex/context/base/font-pre.mkiv
@@ -171,6 +171,22 @@
 \definecolor[font:mark][r=.75,b=.75] % [m=.75]
 \definecolor[font:rest][g=.75,b=.75] % [c=.75]
 
+\definecolor[trace:r][r=.75,t=.5,a=1]
+\definecolor[trace:g][g=.75,t=.5,a=1]
+\definecolor[trace:b][b=.75,t=.5,a=1]
+\definecolor[trace:c][c=.75,t=.5,a=1]
+\definecolor[trace:m][m=.75,t=.5,a=1]
+\definecolor[trace:y][y=.75,t=.5,a=1]
+\definecolor[trace:s][s=.75,t=.5,a=1]
+
+\definecolor[trace:dr][r=.75,t=.75,a=1]
+\definecolor[trace:dg][g=.75,t=.75,a=1]
+\definecolor[trace:db][b=.75,t=.75,a=1]
+\definecolor[trace:dc][c=.75,t=.75,a=1]
+\definecolor[trace:dm][m=.75,t=.75,a=1]
+\definecolor[trace:dy][y=.75,t=.75,a=1]
+\definecolor[trace:ds][s=.75,t=.75,a=1]
+
 %D Now we're up to some definitions.
 
 \definebodyfontenvironment
diff --git a/tex/context/base/font-sol.mkiv b/tex/context/base/font-sol.mkiv
deleted file mode 100644
index d2808feb2..000000000
--- a/tex/context/base/font-sol.mkiv
+++ /dev/null
@@ -1,123 +0,0 @@
-%D \module
-%D   [       file=font-sol,
-%D        version=2009.05.19,
-%D          title=\CONTEXT\ Font Macros,
-%D       subtitle=Solutions,
-%D         author=Hans Hagen,
-%D           date=\currentdate,
-%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\writestatus{loading}{ConTeXt Node Support / Splitters}
-
-% todo: pass color for tracing
-
-%D This module is specially made for the oriental \TEX\ project. The working is as
-%D follows (and tuned for fonts like Idris' Husayni. The following method came to
-%D my mind after a couple of Skype sessions with Idris while working on the rough
-%D edges of the Husayni font and playing with font dynamics.
-%D
-%D \startitemize[packed]
-%D
-%D \item We define a couple of features sets, some can have stylistics variants
-%D       that result in the same words getting a different width. Normally this
-%D       happens in a goodies file.
-%D
-%D \item We group such features in a solution set. A solutionset can be enabled
-%D       by setting an attribute.
-%D
-%D \item For each paragraph we identify words that get this set applied. We replace
-%D       these words by a user node that refers to the original.
-%D
-%D \item For each word we apply the features to a copy that we associate with this
-%D       original word.
-%D
-%D \item At the end we have a paragraph (node list) with user nodes that point to a
-%D       cache that has originals and processed variants.
-%D
-%D \item When the paragraph is broken into lines we optimize the spacing by
-%D       substituting variants.
-%D
-%D \stopitemize
-%D
-%D This approach permits us to use a dedicated paragraph builder, one that treats
-%D the user nodes special and takes the alternatives into account.
-%D
-%D Currently we assume only one solution being active. Maybe some day I'll support
-%D a mixture. This is only one way of optimizing and after several experiments this
-%D one was chosen as testcase. It took quite some experiments (and time) to get thus
-%D far.
-%D
-%D The is experimental code for the Oriental \TEX\ project and aspects of it might
-%D change.
-%D
-%D \starttyping
-%D \setupfontsolutions[method={random,preroll},criterium=1,randomseed=101]
-%D
-%D \definefontsolution % actually only the last run needs to be done this way
-%D   [FancyHusayni]
-%D   [goodies=husayni,
-%D    solution=experimental]
-%D
-%D \definedfont[husayni*husayni-default at 24pt]
-%D \setupinterlinespace[line=36pt]
-%D \righttoleft
-%D \enabletrackers[parbuilders.solutions.splitters.colors]
-%D \setfontsolution[FancyHusayni]
-%D alb alb alb \par
-%D \resetfontsolution
-%D \disabletrackers[parbuilders.solutions.splitters.colors]
-%D \stoptyping
-
-\registerctxluafile{font-sol}{1.001}
-
-\unprotect
-
-\definesystemattribute[splitter][public]
-
-\installcorenamespace{fontsolution}
-
-\installcommandhandler \??fontsolution {fontsolution} \??fontsolution
-
-\let\setupfontsolutions\setupfontsolution
-
-\appendtoks
-    \ctxcommand{definefontsolution("\currentfontsolution",{ % these are frozen
-        goodies  = "\fontsolutionparameter\s!goodies",
-        solution = "\fontsolutionparameter\c!solution",
-        less     = "\fontsolutionparameter\c!less",
-        more     = "\fontsolutionparameter\c!more",
-    })}
-\to \everydefinefontsolution
-
-\unexpanded\def\setfontsolution[#1]% just one
-  {\edef\currentfontsolution{#1}%
-   \ctxcommand{setfontsolution("\currentfontsolution",{
-        method     = "\fontsolutionparameter\c!method",
-        criterium  = "\fontsolutionparameter\c!criterium",
-      % randomseed = "\fontsolutionparameter\c!random",
-  })}}
-
-\unexpanded\def\resetfontsolution % resets all
-  {\ctxcommand{resetfontsolution()}%
-   \let\currentfontsolution\empty}
-
-\unexpanded\def\startfontsolution % [#1]
-  {\pushmacro\currentfontsolution
-   \setfontsolution}
-
-\unexpanded\def\stopfontsolution
-  {\ifhmode\par\fi
-   \ctxcommand{stopfontsolution()}%
-   \popmacro\currentfontsolution}
-
-% We initialize this module at the \LUA\ end.
-%
-% \setupfontsolutions
-%   [\c!method={\v!normal,preroll},
-%    \c!criterium=0]
-
-\protect
diff --git a/tex/context/base/font-sol.mkvi b/tex/context/base/font-sol.mkvi
new file mode 100644
index 000000000..b40e37ced
--- /dev/null
+++ b/tex/context/base/font-sol.mkvi
@@ -0,0 +1,123 @@
+%D \module
+%D   [       file=font-sol,
+%D        version=2009.05.19,
+%D          title=\CONTEXT\ Font Macros,
+%D       subtitle=Solutions,
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Node Support / Splitters}
+
+% todo: pass color for tracing
+
+%D This module is specially made for the oriental \TEX\ project. The working is as
+%D follows (and tuned for fonts like Idris' Husayni. The following method came to
+%D my mind after a couple of Skype sessions with Idris while working on the rough
+%D edges of the Husayni font and playing with font dynamics.
+%D
+%D \startitemize[packed]
+%D
+%D \item We define a couple of features sets, some can have stylistics variants
+%D       that result in the same words getting a different width. Normally this
+%D       happens in a goodies file.
+%D
+%D \item We group such features in a solution set. A solutionset can be enabled
+%D       by setting an attribute.
+%D
+%D \item For each paragraph we identify words that get this set applied. We replace
+%D       these words by a user node that refers to the original.
+%D
+%D \item For each word we apply the features to a copy that we associate with this
+%D       original word.
+%D
+%D \item At the end we have a paragraph (node list) with user nodes that point to a
+%D       cache that has originals and processed variants.
+%D
+%D \item When the paragraph is broken into lines we optimize the spacing by
+%D       substituting variants.
+%D
+%D \stopitemize
+%D
+%D This approach permits us to use a dedicated paragraph builder, one that treats
+%D the user nodes special and takes the alternatives into account.
+%D
+%D Currently we assume only one solution being active. Maybe some day I'll support
+%D a mixture. This is only one way of optimizing and after several experiments this
+%D one was chosen as testcase. It took quite some experiments (and time) to get thus
+%D far.
+%D
+%D The is experimental code for the Oriental \TEX\ project and aspects of it might
+%D change.
+%D
+%D \starttyping
+%D \setupfontsolutions[method={random,preroll},criterium=1,randomseed=101]
+%D
+%D \definefontsolution % actually only the last run needs to be done this way
+%D   [FancyHusayni]
+%D   [goodies=husayni,
+%D    solution=experimental]
+%D
+%D \definedfont[husayni*husayni-default at 24pt]
+%D \setupinterlinespace[line=36pt]
+%D \righttoleft
+%D \enabletrackers[parbuilders.solutions.splitters.colors]
+%D \setfontsolution[FancyHusayni]
+%D alb alb alb \par
+%D \resetfontsolution
+%D \disabletrackers[parbuilders.solutions.splitters.colors]
+%D \stoptyping
+
+\registerctxluafile{font-sol}{1.001}
+
+\unprotect
+
+\definesystemattribute[splitter][public]
+
+\installcorenamespace{fontsolution}
+
+\installcommandhandler \??fontsolution {fontsolution} \??fontsolution
+
+\let\setupfontsolutions\setupfontsolution
+
+\appendtoks
+    \ctxcommand{definefontsolution("\currentfontsolution",{ % these are frozen
+        goodies  = "\fontsolutionparameter\s!goodies",
+        solution = "\fontsolutionparameter\c!solution",
+        less     = "\fontsolutionparameter\c!less",
+        more     = "\fontsolutionparameter\c!more",
+    })}
+\to \everydefinefontsolution
+
+\unexpanded\def\setfontsolution[#solution]% just one
+  {\edef\currentfontsolution{#solution}%
+   \ctxcommand{setfontsolution("\currentfontsolution",{
+        method     = "\fontsolutionparameter\c!method",
+        criterium  = "\fontsolutionparameter\c!criterium",
+      % randomseed = "\fontsolutionparameter\c!random",
+  })}}
+
+\unexpanded\def\resetfontsolution % resets all
+  {\ctxcommand{resetfontsolution()}%
+   \let\currentfontsolution\empty}
+
+\unexpanded\def\startfontsolution % [#1]
+  {\pushmacro\currentfontsolution
+   \setfontsolution}
+
+\unexpanded\def\stopfontsolution
+  {\ifhmode\par\fi
+   \ctxcommand{stopfontsolution()}%
+   \popmacro\currentfontsolution}
+
+% We initialize this module at the \LUA\ end.
+%
+% \setupfontsolutions
+%   [\c!method={\v!normal,preroll},
+%    \c!criterium=0]
+
+\protect
diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv
index 6935ebe7e..55264dd0c 100644
--- a/tex/context/base/grph-fig.mkiv
+++ b/tex/context/base/grph-fig.mkiv
@@ -11,350 +11,198 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-% ex => ef with proper parent
-
-\writestatus{loading}{ConTeXt Graphic Macros / Figure Handling}
-
 \unprotect
 
-\installcorenamespace{externalfigureinstance}
-\installcorenamespace{externalfigurecollection}
-
-\newtoks\everysetupexternalfigures % todo: command handler
-
-\unexpanded\def\setupexternalfigures
-  {\dosingleempty\dosetupexternalfigures}
-
-\def\dosetupexternalfigures[#1]%
-  {\getparameters[\??ef][#1]% local settings
-   \getparameters[\??ex][#1]% global settings
-   \the \everysetupexternalfigures}
-
-\appendtoks
-   \setfigurepathlist  % the path may be used elsewhere too (as in x-res-04)
-\to \everysetupexternalfigures
-
-\appendtoks
-    \ctxcommand{setfigurelookuporder("\@@exorder")}%
-\to \everysetupexternalfigures
-
-\presetlocalframed[\??ef]
+%D Used in the styledesign manual:
+%
+% beware in mkiv we don't have the typeset- prefix
+%
+% \setbuffer[typeset-b]\endbuffer
+% \setbuffer[typeset-a]\endbuffer
+%
+% todo:
+%
+% \appendtoks \setbuffer[typeset-b]\endbuffer\to \everystarttext
+% \appendtoks \setbuffer[typeset-a]\endbuffer\to \everystarttext
 
-\newconditional\externalfigurelevel % true=background false=normal
-\newconditional\externalfigureflush % true=place false=ignore
+\newcount\c_grph_buffers_n
 
-\setfalse\externalfigurelevel
-\settrue \externalfigureflush
+\let\m_grph_buffers_filename\empty
 
-\def\doplaceexternalfigure[#1][#2][#3][#4][#5]%
-  {\doifsomething{#2}% catches \defineexternalfigure dummies
-     {\ifcsname\??externalfigureinstance#2\endcsname
-        \doifelse{#1}{#2}
-          {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]}
-          {\getvalue{\??externalfigureinstance#2}[#5]}%
-      \else
-        \dodoplaceexternalfigure[#1][#2][#3][#4][#5]%
-      \fi}}
+\unexpanded\def\typesetbuffer
+  {\dodoubleempty\grph_buffers_typeset}
 
-\ifdefined\dotagfigure \else \let\dotagfigure\relax \fi
+\def\grph_buffers_typeset[#1][#2]% beware: this will mix up the mp graphics
+  {\ifsecondargument
+     \grph_buffers_typeset_indeed[#1][#2]%
+   \else\iffirstargument
+     \doifassignmentelse{#1}
+       {\grph_buffers_typeset_indeed[\jobname][#1]}%
+       {\grph_buffers_typeset_indeed[#1][]}%
+   \else
+     \grph_buffers_typeset_indeed[\jobname][]
+   \fi\fi}
 
-\def\dodoplaceexternalfigure[#1][#2][#3][#4][#5]%
+\def\grph_buffers_typeset_indeed[#1][#2]% we could use the via files
   {\bgroup
-   \dostarttagged\t!image\empty
-   \let\textunderscore\letterunderscore % {\string _} % space needed as _ is now letter in unprotected mode
-   \calculateexternalfigure[][#1][#2][#3][#4][#5]% [] is dummy dwcomp
-   \dotagfigure
-   \naturalvbox attr \imageattribute 2 {\box\foundexternalfigure}%
-   \dostoptagged
+   \global\advance\c_grph_buffers_n\plusone
+   \edef\m_grph_buffers_filename{\jobname-buffer-\the\c_grph_buffers_n}%
+   \ctxcommand{runbuffer("\m_grph_buffers_filename.tmp","#1",true)}%
+   \externalfigure[\m_grph_buffers_filename.pdf][#2]%
    \egroup}
 
-\def\externalfigurereplacement#1#2#3%
-  {\normalexpanded{\localframed
-     [\??ef]
-     [\c!width=\figurewidth,
-      \c!height=\figureheight,
-      \c!background=\v!color,
-      \c!backgroundcolor=missingfigurecolor,
-      \c!frame=\@@efframe]}% we need to expand this in order to prevent a loop
-     {\tt\tfxx \nohyphens
-        name:  \expanded{\verbatimstring{#1}}\\%
-        file:  \expanded{\verbatimstring{#2}}\\%
-        state: \expanded{\verbatimstring{#3}}}}
-
-\definecolor[missingfigurecolor][s=.8]
-
-\def\externalfigureplaceholder#1#2#3%
-  {\localframed
-     [\??ef]
-     [\c!width=#2,
-      \c!height=#3,
-      \c!frame=\v!on]%
-     {\tt\tfxx \nohyphens
-        name:  \expanded{\verbatimstring{#1}}\\%
-        state: \expanded{\verbatimstring{placeholder}}}}
-
-% new: more convenient/efficient than
-%
-%   \use..[a][a][setting] \externalfigure[b][a]
-%
-% is equivalent to:
-%
-%   \def..[a][setting]    \externalfigure[b][a]
-%
-% see x-res modules for usage:
+% For manuals and such:
 %
-% \defineexternalfigure[name][settings]
-
-\unexpanded\def\defineexternalfigure
-  {\dodoubleargument\dodefineexternalfigure}
-
-\def\dodefineexternalfigure[#1][#2]%
-  {\setvalue{\??externalfigureinstance#1}{\doplaceexternalfigure[#1][][][#2]}}
-
-% \useexternalfigure[alpha][koe]
-% \useexternalfigure[beta] [koe]       [breedte=1cm]
-% \useexternalfigure[gamma][koe][alpha]
-% \useexternalfigure[delta][koe][alpha][breedte=2cm]
+% \definetypesetting [name] [options]   [settings-a]
 %
-% volle breedte: \externalfigure[koe]                 \par
-% 3cm breed:     \externalfigure[koe]  [breedte=3cm]  \par
-% volle breedte: \externalfigure[alpha]               \par
-% 1cm breed:     \externalfigure[beta]                \par
-% volle breedte: \externalfigure[gamma]               \par
-% 2cm breed:     \externalfigure[delta]               \par
-% 4cm breed:     \externalfigure[beta] [breedte=4cm]  \par
-% 5cm breed:     \externalfigure[gamma][breedte=5cm]  \par
-
-% \defineexternalfigure[a][width=10cm]
-% \defineexternalfigure[b][width=5cm]
-% \externalfigure[cow][a]
-% \externalfigure[cow][b][height=8cm]
-
-% \useexternalfigure[x][cow][width=10cm,height=1cm]
-% \externalfigure[x]
-% \externalfigure[x][width=3cm]
+% \typesetfile       [name] [file]      [settings-b]
+% \typesetfile       [file] [options]   [settings-b]
+% \typesetfile       [file] [settings-b]
+% \typesetfile       [file]
 %
-% [label] [filename]
-% [label] [filename] [parent]
-% [label] [filename] [parent] [settings]
-% [label] [filename]          [settings]
-
-\def\useexternalfigure
-  {\doquadrupleempty\douseexternalfigure}
-
-\def\douseexternalfigure[#1][#2][#3][#4]%
-  {\doifelsenothing{#1}
-     {\doifsomething{#2}
-        {\doifassignmentelse{#3}
-           {\dodouseexternalfigure{#2}{#2}{#3}{#4}}
-           {\dodouseexternalfigure{#2}{#2}{}{#4}}}}
-     {\doifelsenothing{#2}
-        {\doifassignmentelse{#3}
-           {\dodouseexternalfigure{#1}{#1}{}{#3}}
-           {\dodouseexternalfigure{#1}{#1}{#3}{#4}}}
-        {\doifassignmentelse{#3}
-           {\dodouseexternalfigure{#1}{#2}{}{#3}}
-           {\dodouseexternalfigure{#1}{#2}{#3}{#4}}}}}
-
-\def\dodouseexternalfigure#1#2#3#4%
-  {\setvalue{\??externalfigureinstance#1}{\doplaceexternalfigure[#1][#2][#3][#4]}%
-   \doanalyzeexternalfigurecollection[#2][#4]}
-
-\newconditional\inexternalfigurecollection
-\newdimen\xexternalfigurecollectionminwidth
-\newdimen\xexternalfigurecollectionmaxwidth
-\newdimen\xexternalfigurecollectionminheight
-\newdimen\xexternalfigurecollectionmaxheight
-
-\def\doanalyzeexternalfigurecollection[#1][#2]%
-  {\ifconditional\inexternalfigurecollection
-      \setfalse\inexternalfigurecollection
-      \getfiguredimensions[#1][#2]%
-      \settrue\inexternalfigurecollection
-      \scratchdimen\naturalfigurewidth
-      \ifdim\scratchdimen>\xexternalfigurecollectionmaxwidth  \xexternalfigurecollectionmaxwidth \scratchdimen \fi
-      \ifdim\scratchdimen<\xexternalfigurecollectionminwidth  \xexternalfigurecollectionminwidth \scratchdimen \fi
-      \scratchdimen\naturalfigureheight
-      \ifdim\scratchdimen>\xexternalfigurecollectionmaxheight \xexternalfigurecollectionmaxheight\scratchdimen \fi
-      \ifdim\scratchdimen<\xexternalfigurecollectionminheight \xexternalfigurecollectionminheight\scratchdimen \fi
-   \fi}
-
-\unexpanded\def\startexternalfigurecollection[#1]%
-  {\begingroup
-   \def\currentexternalfigurecollection{#1}%
-   \settrue\inexternalfigurecollection
-   \xexternalfigurecollectionminwidth \maxdimen
-   \xexternalfigurecollectionmaxwidth \zeropoint
-   \xexternalfigurecollectionminheight\maxdimen
-   \xexternalfigurecollectionmaxheight\zeropoint}
-
-\unexpanded\def\stopexternalfigurecollection
-  {\setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!minwidth }{\the\xexternalfigurecollectionminwidth }%
-   \setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!maxwidth }{\the\xexternalfigurecollectionmaxwidth }%
-   \setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!minheight}{\the\xexternalfigurecollectionminheight}%
-   \setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!maxheight}{\the\xexternalfigurecollectionmaxheight}%
-   \endgroup}
-
-\def\externalfigurecollectionparameter#1#2%
-  {\csname
-     \ifcsname\??externalfigurecollection#1:#2\endcsname
-       \??externalfigurecollection#1:#2%
-     \else
-       \s!empty
-     \fi
-   \endcsname}
-
-\def\externalfigurecollectionminwidth #1{\externalfigurecollectionparameter{#1}\c!minwidth }
-\def\externalfigurecollectionmaxwidth #1{\externalfigurecollectionparameter{#1}\c!maxwidth }
-\def\externalfigurecollectionminheight#1{\externalfigurecollectionparameter{#1}\c!minheight}
-\def\externalfigurecollectionmaxheight#1{\externalfigurecollectionparameter{#1}\c!maxheight}
-
-\let\efcparameter\externalfigurecollectionparameter
-\let\efcminwidth \externalfigurecollectionminwidth
-\let\efcmaxwidth \externalfigurecollectionmaxwidth
-\let\efcminheight\externalfigurecollectionminheight
-\let\efcmaxheight\externalfigurecollectionmaxheight
-
-% \startexternalfigurecollection[name]
-%     \useexternalfigure[cow] [cow.pdf]
-%     \useexternalfigure[mill][mill.png]
-% \stopexternalfigurecollection
+% \enabletrackers[files.run]
 % \starttext
-% \bTABLE
-%     \bTR
-%         \bTD \externalfigure[cow] [height=\externalfigurecollectionmaxheight{name}] \eTD
-%         \bTD \externalfigure[mill][height=\externalfigurecollectionmaxheight{name}] \eTD
-%     \eTR
-% \eTABLE
+%     \typesetfile[oepsoeps.tex][width=10cm,frame=on]
 % \stoptext
 
-\def\dosetefparameters#1#2#3% parent_id use_settings current_settings
-  {\doifelsenothing{#1} % inherit from parent
-     {\getparameters[\??ef][#2,#3]}
-     {\ifcsname\??externalfigureinstance#1\endcsname
-        \pushmacro\doplaceexternalfigure
-        \def\doplaceexternalfigure[##1][##2][##3][##4]{\getparameters[\??ef][##4,#2,#3]}%
-        \getvalue{\??externalfigureinstance#1}%
-        \popmacro\doplaceexternalfigure
-      \else
-        \getparameters[\??ef][#2,#3]%
-      \fi}}
-
-\unexpanded\def\externalfigure
-  {\dotripleempty\doexternalfigure}
-
-\def\doexternalfigure[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings]
-  {\bgroup % also catched #1 == empty ... scales nicer now
-   \ifcsname\??externalfigureinstance#1\endcsname
-     \doifassignmentelse{#2}
-       {\getvalue{\??externalfigureinstance#1}[#2]}%
-       {\getvalue{\??externalfigureinstance#1}[#3]}%
-   \else
-     \useexternalfigure[\s!dummy][#1][#2][#3]%
-     \getvalue{\??externalfigureinstance\s!dummy}[]% [] is dummy arg 5
-   \fi
-   \globallet\currentresourcecomment\empty
-   \egroup}
-
-\def\resourcecomment#1%
-  {\gdef\currentresourcecomment{#1}}
+\installcorenamespace{typesettingfile}
 
-\unexpanded\def\startresourcecomment#1\stopresourcecomment
-  {\gdef\currentresourcecomment{#1}}
+\unexpanded\def\definetypesetting{\dotripleempty\grph_typesetting_define}
+\unexpanded\def\typesetfile      {\dotripleempty\grph_typesetting_process}
 
-\let\currentresourcecomment\empty
+\def\grph_typesetting_define[#1][#2][#3]% <name> options settings-a
+  {\doifsomething{#1}{\setuvalue{\??typesettingfile#1}{\grph_typesetting_process_indeed{#2}{#3}}}}
 
-\unexpanded\def\showexternalfigures % maybe run time command is better, but no core-run, unless figs-run ...
-  {%\writestatus\m!system{for \string\showexternalfigures\space see \truefilename{x-res-20}.tex}
-   \usemodule[res-20]%
-   \showexternalfigures} % so for the moment we do it this way
+\def\grph_typesetting_process[#1][#2][#3]% <name> filename settings-b | filename options settings
+  {\ifcsname\??typesettingfile#1\endcsname
+     \csname\??typesettingfile#1\endcsname{#2}{#3}%
+   \else\ifthirdargument % filename options settings
+     \grph_typesetting_process_indeed{#2}{#3}{#1}{}%
+   \else\ifsecondargument % filename settings
+     \grph_typesetting_process_indeed{}{#2}{#1}{}%
+   \fi\fi\fi}
 
-\unexpanded\def\overlayfigure#1%
-  {\externalfigure[#1][\c!width=\overlaywidth,\c!height=\overlayheight]}
+\def\grph_typesetting_process_indeed#1#2#3#4% options settings-a filename settings-b
+  {\begingroup
+   \edef\m_typesetting_name{\cldcontext{job.files.context("#3","#1")}}%
+   \ifx\m_typesetting_name\empty \else
+     \expanded{\externalfigure[\m_typesetting_name]}[#2,#4]%
+   \fi
+   \endgroup}
 
-%D Whatever
+%D Whatever ... hardly used ... but historic ... needs checking ...
+%D will probably become m-fig-nn.mkiv .. or I will extend it cq. clean
+%D it up when I needed it. After all, it's documented in old manuals.
 
-\newbox\colorbarbox
+\newcount\c_grph_steps_reference
+\newdimen\d_grph_steps_x
+\newdimen\d_grph_steps_y
+\newbox  \b_grph_steps_colorbar
 
-\unexpanded\def\makecolorbar[#1]%
-  {\def\docommand##1%
-     {\color[##1]
-        {\blackrule
-           [\c!width=2\emwidth,
-            \c!height=\exheight,
-            \c!depth=\zeropoint]}%
-      \endgraf}%
-   \global\setbox\colorbarbox\vbox
-     {\forgetall
-      \processcommalist[#1]\docommand}%
-   \global\setbox\colorbarbox\vbox
-     {\hskip2em\box\colorbarbox}%
-   \wd\colorbarbox\zeropoint}
+\let\placestopfigure\relax
 
 \unexpanded\def\placestartfigure[#1][#2][#3]#4\placestopfigure[#5]%
   {\hbox
-     {\setbox0\hbox
+     {\setbox\scratchbox\hbox
         {\useexternalfigure[\s!dummy][#2][#3,#5]%
          \externalfigure[\s!dummy]}%
-      \calculateefsteps
+      \grph_steps_calculate
       \startpositioning
-        \def\referring(##1,##2)##3(##4,##5)##6[##7]%
-          {\position(##1,##2){\efgoto(##4,##5){\@@exframes}[##7]}}%
-        \def\marking(##1,##2)##3(##4,##5)##6[##7]%
-          {\position(##1,##2){\efthisis(##4,##5){\@@exframes}[##7]}}%
-        \def\remark{\efnocomment}%
-        \def\colorbar##1[##2]{}%
-        \position(0,0){\box0}%
+        \let\referring\grph_steps_one_referring
+        \let\marking  \grph_steps_one_marking
+        \let\remark   \grph_steps_one_remark
+        \let\colorbar \grph_steps_one_colorbar
+        \position(0,0){\box\scratchbox}%
         \linewidth\onepoint
         \setuppositioning
           [\c!unit=pt,
-           \c!xscale=\withoutpt\the\efxsteps,
-           \c!yscale=\withoutpt\the\efysteps,
+           \c!xscale=\withoutpt\the\d_grph_steps_x,
+           \c!yscale=\withoutpt\the\d_grph_steps_y,
            \c!factor=1]%
         \ignorespaces#4%
-        \def\referring(##1,##2)##3(##4,##5)##6[##7]%
-          {}%
-        \let\marking\referring
-        \def\remark{\efcomment\v!no}%
-        \def\colorbar##1[##2]{\makecolorbar[##2]}%
+        \let\referring\grph_steps_two_referring
+        \let\marking  \grph_steps_two_marking
+        \let\remark   \grph_steps_two_remark
+        \let\colorbar \grph_steps_two_colorbar
         \ignorespaces#4%
       \stoppositioning
-      \box\colorbarbox}}
+      \ifvoid\b_grph_steps_colorbar\else\box\b_grph_steps_colorbar\fi}} % not really needed
 
-\def\dodostartfigure[#1][#2][#3]#4\stopfigure
-  {\doifelse\v!test\@@exoption
+\unexpanded\def\grph_steps_one_referring(#1,#2)#3(#4,#5)#6[#7]%
+  {\position(#1,#2){\grph_steps_goto(#4,#5){\externalfiguresparameter\c!frames}[#7]}}
+
+\unexpanded\def\grph_steps_one_marking(#1,#2)#3(#4,#5)#6[#7]%
+  {\position(#1,#2){\grph_steps_this_is(#4,#5){\externalfiguresparameter\c!frames}[#7]}}
+
+\unexpanded\def\grph_steps_one_remark(#1,#2)#3(#4,#5)%    (x,y)(h,b)[...]{tekst}
+  {\def\grph_steps_no_comment_indeed[##1]##2{}%
+   \dosingleempty\grph_steps_no_comment_indeed}
+
+\unexpanded\def\grph_steps_one_colorbar#1[#2]%
+  {}
+
+\unexpanded\def\grph_steps_two_referring(#1,#2)#3(#4,#5)#6[#7]%
+  {}
+
+\let\grph_steps_two_marking\grph_steps_two_referring
+
+\unexpanded\def\grph_steps_two_remark
+  {\grph_steps_comment\v!no}
+
+\unexpanded\def\grph_steps_two_colorbar#1[#2]
+  {\begingroup
+   \global\setbox\b_grph_steps_colorbar\vbox
+     {\forgetall
+      \processcommalist[#2]\grph_colorbar_make_step}%
+   \global\setbox\b_grph_steps_colorbar\vbox
+     {\hskip2\emwidth\box\b_grph_steps_colorbar}%
+   \global\wd\b_grph_steps_colorbar\zeropoint
+   \endgroup}
+
+\unexpanded\def\grph_colorbar_make_step#1%
+  {\blackrule[\c!color=#1,\c!width=2\emwidth,\c!height=\exheight,\c!depth=\zeropoint]%
+   \endgraf}
+
+\unexpanded\def\startfigure % could be done nicer
+  {\grabuntil{\e!stop\v!figure}\grph_steps_figure_process}
+
+\let\stopfigure\relax
+
+\def\grph_steps_figure_process#1%
+  {\dotripleargument\grph_steps_figure_process_indeed#1\stopfigure}
+
+\def\grph_steps_figure_process_indeed[#1][#2][#3]#4\stopfigure
+  {\doifelse{\externalfiguresparameter\c!option}\v!test
      {\teststartfigure[#1][#2][#3]#4\teststopfigure
-      \let\@@exframes\v!on}
-     {\let\@@exframes\v!off}%
+      \letexternalfiguresparameter\c!frames\v!on}
+     {\letexternalfiguresparameter\c!frames\v!off}%
    \setvalue{\??externalfigureinstance#1}%
-     {\dosingleempty{\placestartfigure[#1][#2][#3]#4\placestopfigure}}%
-   }% no longer \doifundefined{#1}{\setvalue{#1}{\getexternalfigure{#1}}}}
+     {\dosingleempty{\placestartfigure[#1][#2][#3]#4\placestopfigure}}}
 
-% De onderstaande macro mag niet zondermeer worden aangepast
-% en is afgestemd op gebruik in de handleiding.
+\let\teststopfigure\relax
 
-\def\teststartfigure[#1][#2][#3]#4\teststopfigure%
+\unexpanded\def\teststartfigure[#1][#2][#3]#4\teststopfigure
   {\begingroup
-     \setbox0\hbox
+     \setbox\scratchbox\hbox
        {\useexternalfigure[\s!dummy][#2][\c!wfactor=\v!max]%
         \externalfigure[\s!dummy]}%
-     \def\referring{\efmark}%
-     \def\marking{\efmark}%
-     \def\remark{\efcomment\v!yes}%
-     \def\colorbar##1[##2]{}%
-     \efreference\zerocount
+     \let\referring\grph_steps_three_referring
+     \let\marking  \grph_steps_three_marking
+     \let\remark   \grph_steps_three_remark
+     \let\colorbar \grph_steps_three_colorbar
+     \c_grph_steps_reference\zerocount
      \setbox0\vbox
-       {\hsize240pt
+       {\hsize240\points
         \startpositioning
-          \calculateefsteps
+          \grph_steps_calculate
           \position(0,0)
-            {\box0}%
+            {\box\scratchbox}%
           \position(0,0)
             {\basegrid
-               [\c!nx=\@@exxmax,
-                \c!dx=\withoutpt\the\efxsteps,
-                \c!ny=\@@exymax,
-                \c!dy=\withoutpt\the\efysteps,
+               [\c!nx=\externalfiguresparameter\c!xmax,
+                \c!dx=\withoutpt\the\d_grph_steps_x,
+                \c!ny=\externalfiguresparameter\c!ymax,
+                \c!dy=\withoutpt\the\d_grph_steps_y,
                 \c!xstep=1,
                 \c!ystep=1,
                 \c!scale=1,
@@ -362,18 +210,18 @@
                 \c!unit=pt]}%
           \setuppositioning
             [\c!unit=pt,
-             \c!xscale=\withoutpt\the\efxsteps,
-             \c!yscale=\withoutpt\the\efysteps,
+             \c!xscale=\withoutpt\the\d_grph_steps_x,
+             \c!yscale=\withoutpt\the\d_grph_steps_y,
              \c!factor=1]%
           \linewidth\onepoint
           \ignorespaces#4\relax
         \stoppositioning
         \vfill}%
-     \efreference\zerocount
-     \def\referring{\eftext{$\rightarrow$}}%
-     \def\marking{\eftext{$\leftarrow$}}%
-     \def\remark{\efnocomment}%
-     \def\colorbar##1[##2]{}%
+     \c_grph_steps_reference\zerocount
+     \let\referring\grph_steps_four_referring
+     \let\marking  \grph_steps_four_marking
+     \let\remark   \grph_steps_four_remark
+     \let\colorbar \grph_steps_four_colorbar
      \setbox2\vbox
        {{\tfa\doifelsenothing{#1}{#2}{#1}}
         \blank
@@ -385,166 +233,149 @@
        \ht0\ht2
      \fi
      \hbox
-       {\hskip3em
-        \vtop{\vskip12pt\box0\vskip6pt}%
-        \vtop{\vskip12pt\box2\vskip6pt}}%
+       {\hskip3\emwidth
+        \vtop{\vskip12\points\box0\vskip6\points}%
+        \vtop{\vskip12\points\box2\vskip6\points}}%
    \endgroup}
 
-\def\dodostartfigure[#1][#2][#3]#4\stopfigure
-  {\doifelse\v!test\@@exoption
-     {\teststartfigure[#1][#2][#3]#4\teststopfigure
-      \let\@@exframe\v!on}
-     {\let\@@exframe\v!off}%
-   \setvalue{\??externalfigureinstance#1}%
-     {\def\next{\placestartfigure[#1][#2][#3]#4\placestopfigure}%
-      \dosingleempty\next}%
-   }% no longer: \doifundefined{#1}{\setvalue{#1}{\getexternalfigure{#1}}}}
+\unexpanded\def\grph_steps_three_referring(#1,#2)#3(#4,#5)#6[#7]%
+  {\advance\c_grph_steps_reference\plusone
+   \position(#1,#2)
+     {\hbox{\the\c_grph_steps_reference}}%
+   \position(#1,#2)
+     {\gotosomeinternal\s!vwb{#7}\realfolio
+        {\grph_steps_marker(#4,#5)\v!on{\thisissomeinternal\s!vwa{#7}}}}}
 
-\long\def\dostartfigure#1%
-  {\dotripleargument\dodostartfigure#1\stopfigure}
+\unexpanded\def\grph_steps_three_remark
+  {\grph_steps_comment\v!yes}
 
-\unexpanded\def\startfigure
-  {\grabuntil{\e!stop\v!figure}\dostartfigure}
-
-%D NEW: used in styledesign manual
+\let\grph_steps_three_marking \grph_steps_three_referring
+\let\grph_steps_three_colorbar\grph_steps_one_colorbar
 
-% beware in mkiv we don't have the typeset- prefix
-%
-% \setbuffer[typeset-b]\endbuffer
-% \setbuffer[typeset-a]\endbuffer
-%
-% todo:
-%
-% \appendtoks \setbuffer[typeset-b]\endbuffer\to \everystarttext
-% \appendtoks \setbuffer[typeset-a]\endbuffer\to \everystarttext
+\unexpanded\def\grph_steps_four_referring
+  {\grph_steps_text{$\rightarrow$}}
 
-\newcount\noftypesetbuffers
+\unexpanded\def\grph_steps_four_marking
+  {\grph_steps_text{$\leftarrow$}}
 
-\def\typesetbuffer
-  {\dodoubleempty\dotypesetbuffer}
+\let\grph_steps_four_remark  \grph_steps_one_remark
+\let\grph_steps_four_colorbar\grph_steps_one_colorbar
 
-\def\dotypesetbuffer[#1][#2]% beware: this will mix up the mp graphics
-  {\ifsecondargument
-     \dodotypesetbuffer[#1][#2]%
-   \else\iffirstargument
-     \doifassignmentelse{#1}
-       {\dodotypesetbuffer[\jobname][#1]}%
-       {\dodotypesetbuffer[#1][]}%
+% Helpers:
+
+\def\grph_steps_calculate
+  {\ifnum0\externalfiguresparameter\c!xmax=\zerocount
+     \ifnum0\externalfiguresparameter\c!ymax=\zerocount
+       \setexternalfiguresparameter\c!ymax{24}%
+     \fi
+     \d_grph_steps_y\figureheight
+     \divide\d_grph_steps_y \externalfiguresparameter\c!ymax
+     \d_grph_steps_x\d_grph_steps_y
+     \scratchdimen\figurewidth
+     \advance\scratchdimen\d_grph_steps_y
+     \divide \scratchdimen\d_grph_steps_y
+     \setexternalfiguresparameter\c!xmax{\number\scratchdimen}%
    \else
-     \dodotypesetbuffer[\jobname][]
-   \fi\fi}
+     \d_grph_steps_x\figurewidth  \divide\d_grph_steps_x \externalfiguresparameter\c!xmax\relax
+     \d_grph_steps_y\figureheight \divide\d_grph_steps_y \externalfiguresparameter\c!ymax\relax
+   \fi}
 
-\def\dodotypesetbuffer[#1][#2]%
+\def\grph_steps_comment#1(#2,#3)#4(#5,#6)%    {kader}(x,y)(h,b)[...]{tekst}
+  {\def\grph_steps_comment_indeed[##1]##2%
+     {\position(#2,#3)%
+        {\setnostrut
+         \framed
+           [\c!width=#5\d_grph_steps_x,
+            \c!height=#6\d_grph_steps_y,
+            \c!offset=\v!none,
+            \c!frame=#1,
+            ##1]%
+           {##2}}}%
+   \dosingleempty\grph_steps_comment_indeed}
+
+% \def\grph_steps_figure#1%
+%   {\position(0,0){\getvalue{#1}}}
+
+\def\grph_steps_goto(#1,#2)#3[#4]%    (h,b)kader[ref]
+  {\gotobox{\vbox{\grph_steps_area(#1,#2)#3{}}}[#4]}
+
+\def\grph_steps_text#1(#2,#3)#4(#5,#6)#7[#8]%
+  {\advance\c_grph_steps_reference\plusone
+   \hbox
+     {\quad
+      \thisissomeinternal\s!vwb
+        {#8}%
+      \gotosomeinternal\s!vwa{#8}\realfolio
+        {\hbox to 1.5em{\the\c_grph_steps_reference\presetgoto\hfill}}%
+      \quad#1 (#2,#3) (#5,#6) [#8]\hfill}%
+   \endgraf}
+
+\def\grph_steps_this_is(#1,#2)#3[#4]%
+  {\grph_steps_area(#1,#2){#3}{\pagereference[#4]}}
+
+\def\grph_steps_area(#1,#2)#3#4% (h,b){kader}{tekst}
   {\bgroup
-   \global\advance\noftypesetbuffers\plusone
-   \edef\bufferfilename{\jobname-buffer-\the\noftypesetbuffers}%
-   \ctxcommand{runbuffer("\bufferfilename.tmp","#1",true)}%
-   \externalfigure[\bufferfilename.pdf][#2]%
+   \setnostrut
+   \framed
+     [\c!width=#1\d_grph_steps_x,
+      \c!height=#2\d_grph_steps_y,
+      \c!offset=\zeropoint,
+      \c!frame=#3]
+     {#4}%
    \egroup}
 
-\def\dodotypesetbufferindeed#1%
-  {}
+\def\grph_steps_marker(#1,#2)#3#4% (h,b){kader}{tekst}
+  {\framed
+     [\c!width=#1\d_grph_steps_x,
+      \c!height=#2\d_grph_steps_y,
+      \c!offset=\v!none,
+      \c!frame=#3]%
+     {#4}}
+
+\protect \endinput
 
-% for me only (manuals and such)
+% \startbuffer
+% \definecolor [blue]   [c=1,m=.38,y=0,k=.64]
+% \definecolor [yellow] [c=0,m=.28,y=1,k=.06]
 %
-% \definetypesetting [name] [options]   [settings-a]
+% \definespotcolor [blue-100]   [blue]   [p=1]
+% \definespotcolor [yellow-100] [yellow] [p=1]
 %
-% \typesetfile       [name] [file]      [settings-b]
-% \typesetfile       [file] [options]   [settings-b]
-% \typesetfile       [file] [settings-b]
-% \typesetfile       [file]
+% \definemultitonecolor [combicolor]   [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]
 %
-% \enabletrackers[files.run]
-% \starttext
-%     \typesetfile[oepsoeps.tex][width=10cm,frame=on]
-% \stoptext
-
-\installcorenamespace{typesettingfile}
-
-\unexpanded\def\definetypesetting{\dotripleempty\dodefinetypesetting}
-\unexpanded\def\typesetfile      {\dotripleempty\dotypesetfile}
-
-\def\dodefinetypesetting[#1][#2][#3]% <name> options settings-a
-  {\doifsomething{#1}{\setvalue{\??typesettingfile#1}{\dodotypesetfile{#2}{#3}}}}
-
-\def\dotypesetfile[#1][#2][#3]% <name> filename settings-b | filename options settings
-  {\ifcsname\??typesettingfile#1\endcsname
-     \csname\??typesettingfile#1\endcsname{#2}{#3}%
-   \else\ifthirdargument % filename options settings
-     \dodotypesetfile{#2}{#3}{#1}{}%
-   \else\ifsecondargument % filename settings
-     \dodotypesetfile{}{#2}{#1}{}%
-   \fi\fi\fi}
-
-\def\dodotypesetfile#1#2#3#4% options settings-a filename settings-b
-  {\edef\typesetfilename{\ctxlua{tex.write(job.files.context("#3","#1"))}}%
-   \expanded{\externalfigure[\typesetfilename]}[#2,#4]}
-
-\setupexternalfigures
-  [\c!option=,
-   \c!object=\v!yes, % we only check for no
-   \c!reset=\v!no,
-   \c!interaction=\v!none,
-   \c!maxwidth=\@@efwidth,
-   \c!maxheight=\@@efheight,
-   \c!bodyfont=\bodyfontsize,
-   \c!directory=,
-   \c!radius=.5\bodyfontsize,
-   \c!corner=\v!rectangular,
-   \c!frame=\v!off,
-   \c!background=, % new
-   \c!splitcolor=\s!white,
-   \c!order=,
-   \c!conversion=,
-   \c!resolution=,
-   \c!prefix=,
-   \c!cache=,
-%  \c!grid=,
-   \c!equalwidth=,
-   \c!equalheight=,
-   \c!location={\v!local,\v!global}]
-
-\setupexternalfigures
-  [\c!frames=\v!off,
-   \c!ymax=24,
-   \c!xmax=]
-
-\useexternalfigure
-  [buffer] [\jobname.buffer] [\c!object=\v!no]
-
-\protect \endinput
-
-% alternative for positioning
-
-% \definelayer[figure][width=\overlaywidth,height=\overlayheight]
-% \defineoverlay[figure][{\directsetup{figure}\tightlayer[figure]}]
-
-% \setupcolors[state=start]
-
-% \starttext
-
-%     \startsetups figure
-%         \setlayerframed[figure][preset=rightbottom,x=.25\layerwidth,y=.25\layerheight]{HERE}
-%         \setlayerframed[figure][preset=leftbottom, x=.15\layerwidth,y=.35\layerheight]{THERE}
-%     \stopsetups
-
-%     \externalfigure[cow][background={foreground,figure},width=4cm,height=8cm]
-
-%     \startsetups figure
-%         \setlayerframed[figure][preset=righttop,x=.25\layerwidth,y=.25\layerheight]{MORE}
-%         \setlayerframed[figure][preset=middle,foregroundcolor=green]{EVEN MORE}
-%     \stopsetups
-
-%     \externalfigure[cow][background={foreground,figure},width=14cm,height=2cm]
-
-%     \defineexternalfigure[whatever][background={foreground,figure}]
-
-%     \startsetups figure
-%         \setlayerframed[figure][preset=righttop,x=.25\layerwidth,y=.25\layerheight]{\red MORE}
-%         \setlayerframed[figure][preset=middle,foregroundcolor=green]{EVEN MORE}
-%     \stopsetups
-
-%     \externalfigure[cow][whatever][width=14cm,height=4cm]
-
-% \stoptext
-
+% \definemultitonecolor [combicolor-b] [blue=1]   [c=1,m=.38,y=0,k=.64] % force multitone
+% \definemultitonecolor [combicolor-y] [yellow=1] [c=0,m=.28,y=1,k=.06] % force multitone
+%
+% \useexternalfigure[demo-a][mill.png]     [object=no,width=.2\textwidth]
+% \useexternalfigure[demo-b][hacker-bw.jpg][object=no,width=.2\textwidth]
+%
+% \startbaselinecorrection \startcombination[4*1]
+%   {\externalfigure[demo-a]}                     {no color}
+%   {\externalfigure[demo-a][color=combicolor]}   {indexed duotone}
+%   {\externalfigure[demo-a][color=combicolor-b]} {spot color}
+%   {\externalfigure[demo-a][color=combicolor-y]} {spot color}
+% \stopcombination \stopbaselinecorrection
+%
+% \startbaselinecorrection \startcombination[4*1]
+%   {\externalfigure[demo-b]}                     {no color}
+%   {\externalfigure[demo-b][color=combicolor]}   {indexed duotone}
+%   {\externalfigure[demo-b][color=combicolor-b]} {spot color}
+%   {\externalfigure[demo-b][color=combicolor-y]} {spot color}
+% \stopcombination \stopbaselinecorrection
+%
+% \startbaselinecorrection \startcombination[4*1]
+%   {\externalfigure[demo-a]}                     {no color}
+%   {\externalfigure[demo-a][color=combicolor]}   {indexed duotone}
+%   {\externalfigure[demo-a][color=blue-100]}     {spot color}
+%   {\externalfigure[demo-a][color=yellow-100]}   {spot color}
+% \stopcombination \stopbaselinecorrection
+%
+% \startbaselinecorrection \startcombination[4*1]
+%   {\externalfigure[demo-b]}                     {no color}
+%   {\externalfigure[demo-b][color=combicolor]}   {indexed duotone}
+%   {\externalfigure[demo-b][color=blue-100]}     {spot color}
+%   {\externalfigure[demo-b][color=yellow-100]}   {spot color}
+% \stopcombination \stopbaselinecorrection
+% \stopbuffer
+%
+% \getbuffer \typebuffer
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index 633130ea9..8c191e05e 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -13,14 +13,6 @@
 
 \writestatus{loading}{ConTeXt Graphic Macros / Figure Inclusion}
 
-%D todo:
-%D
-%D - color conversion
-%D - alternative images
-%D - a few more obscure things
-
-% use framedcommandhandler
-
 \registerctxluafile{grph-inc}{1.001}
 \registerctxluafile{grph-fil}{1.001}
 \registerctxluafile{grph-u3d}{1.001} % this will change
@@ -28,25 +20,263 @@
 
 \unprotect
 
-%D The following registers are used (if only to be downward compatible).
+%D Including graphics is complicated by the fact that  we need to locate them first,
+%D optionally manipulate them and scale then next. Lookups are to be done as efficient
+%D as possible and inclusion of the data might happens only once. In \MKIV\ much of this
+%D is delegated to the \LUA\ end. There is nor so much less code as in \MKII\ but it's
+%D more powerful, flexible, pluggable and some of the extended functionality has been
+%D moved from modules to the core. The overall functionality is rather stable and has
+%D not changed much over the years.
+
+\ifdefined\dotagfigure \else \let\dotagfigure\relax \fi
+
+\installcorenamespace{externalfigures}
+\installcorenamespace{externalfigureinstance}
+\installcorenamespace{externalfigurecollection}
+
+\installframedcommandhandler \??externalfigures {externalfigures} \??externalfigures
+
+\setupexternalfigures[% we really need the defaults
+   \c!method         =,
+   \c!label          =,
+   \c!size           =,
+   \c!conversion     =,
+   \c!resolution     =,
+   \c!prefix         =,
+   \c!cache          =,
+   \c!page           =\zerocount,
+   \c!display        =,
+   \c!mask           =,
+   \c!preset         =\v!yes,
+   \c!split          =,
+   \c!color          =,
+   \c!symbol         =\v!no,
+   \c!controls       =\v!no,
+   \c!resources      =,
+   \c!preview        =\v!no
+   \c!repeat         =\v!no
+   \c!foregroundcolor=,
+   \c!interaction    =\v!none,
+   \c!hfactor        =,
+   \c!wfactor        =,
+   \c!factor         =,
+   \c!maxwidth       =\externalfiguresparameter\c!width,
+   \c!maxheight      =\externalfiguresparameter\c!height,
+   \c!xscale         =,
+   \c!yscale         =,
+   \c!scale          =,
+   \c!sx             =1,
+   \c!sy             =1,
+   \c!width          =,
+   \c!height         =,
+   \c!lines          =,
+   \c!grid           =,
+   \c!bodyfont       =\bodyfontsize,
+   \c!object         =\v!yes,
+   \c!corner         =\v!rectangular,
+   \c!frame          =\v!off,
+   \c!option         =,
+   \c!reset          =\v!no,
+   \c!directory      =,
+   \c!radius         =.5\bodyfontsize,
+   \c!background     =,
+   \c!splitcolor     =\s!white,
+   \c!order          =,
+   \c!equalwidth     =,
+   \c!equalheight    =,
+   \c!location       ={\v!local,\v!global},
+   \c!frames         =\v!off,
+   \c!ymax           =24,
+   \c!xmax           =,
+  ]
+
+%D Defining figures.
+
+\newcount\c_grph_include_nesting
+
+\newtoks \everyexternalfigureresets % for the moment still public
+\newtoks \everyexternalfigurechecks % for the moment still public
+
+% \useexternalfigure[alpha][koe]
+% \useexternalfigure[beta] [koe]       [breedte=1cm]
+% \useexternalfigure[gamma][koe][alpha]
+% \useexternalfigure[delta][koe][alpha][breedte=2cm]
+%
+% volle breedte: \externalfigure[koe]                 \par
+% 3cm breed:     \externalfigure[koe]  [breedte=3cm]  \par
+% volle breedte: \externalfigure[alpha]               \par
+% 1cm breed:     \externalfigure[beta]                \par
+% volle breedte: \externalfigure[gamma]               \par
+% 2cm breed:     \externalfigure[delta]               \par
+% 4cm breed:     \externalfigure[beta] [breedte=4cm]  \par
+% 5cm breed:     \externalfigure[gamma][breedte=5cm]  \par
+%
+% \defineexternalfigure[a][width=10cm]
+% \defineexternalfigure[b][width=5cm]
+% \externalfigure[cow][a]
+% \externalfigure[cow][b][height=8cm]
+%
+% \useexternalfigure[x][cow][width=10cm,height=1cm]
+% \externalfigure[x]
+% \externalfigure[x][width=3cm]
+%
+% [label] [filename]
+% [label] [filename] [parent]
+% [label] [filename] [parent] [settings]
+% [label] [filename]          [settings]
+%
+% new: more convenient/efficient than
+%
+%   \use..[a][a][setting] \externalfigure[b][a]
+%
+% is equivalent to:
+%
+%   \def..[a][setting]    \externalfigure[b][a]
+%
+% see x-res modules for usage:
+%
+% \defineexternalfigure[name][settings]
+
+\unexpanded\def\defineexternalfigure
+  {\dodoubleargument\grph_include_define}
+
+\def\grph_include_define[#1][#2]%
+  {\setvalue{\??externalfigureinstance#1}{\grph_include_use[#1][][][#2]}}
+
+\def\useexternalfigure
+  {\doquadrupleempty\grph_include_use}
+
+\def\grph_include_use[#1][#2][#3][#4]%
+  {\doifelsenothing{#1}
+     {\doifsomething{#2}
+        {\doifassignmentelse{#3}
+           {\grph_include_use_indeed{#2}{#2}{#3}{#4}}
+           {\grph_include_use_indeed{#2}{#2}{}{#4}}}}
+     {\doifelsenothing{#2}
+        {\doifassignmentelse{#3}
+           {\grph_include_use_indeed{#1}{#1}{}{#3}}
+           {\grph_include_use_indeed{#1}{#1}{#3}{#4}}}
+        {\doifassignmentelse{#3}
+           {\grph_include_use_indeed{#1}{#2}{}{#3}}
+           {\grph_include_use_indeed{#1}{#2}{#3}{#4}}}}}
+
+\def\grph_include_use_indeed#1#2#3#4%
+  {\setvalue{\??externalfigureinstance#1}{\grph_include_place[#1][#2][#3][#4]}%
+   \grph_include_analyze_collection[#2][#4]}
+
+\def\grph_include_place[#1][#2][#3][#4][#5]%
+  {\doifsomething{#2}% catches \defineexternalfigure dummies
+     {\ifcsname\??externalfigureinstance#2\endcsname
+        \doifelse{#1}{#2}
+          {\grph_include_place_indeed[#1][#2][#3][#4][#5]}
+          {\csname\??externalfigureinstance#2\endcsname[#5]}%
+      \else
+        \grph_include_place_indeed[#1][#2][#3][#4][#5]%
+      \fi}}
 
-\newbox  \foundexternalfigure
-\newif   \ifskipexternalfigures
-\newtoks \everyexternalfigureresets
-\newtoks \everyexternalfigurechecks
-\newtoks \externalfigurepostprocessors
+\def\grph_include_place_indeed[#1][#2][#3][#4][#5]%
+  {\bgroup
+   \advance\c_grph_include_nesting\plusone
+   \edef\currentexternalfigures{\the\c_grph_include_nesting}%
+   \checkexternalfiguresparent % each inherits from the root
+   %
+   \dostarttagged\t!image\empty
+   %
+   \let\textunderscore\letterunderscore % {\string _} % space needed as _ is now letter in unprotected mode (probably no longer needed)
+   %
+   \dontcomplain
+   \restorecatcodes
+   \forgetall
+   %
+   \the\everyexternalfigureresets
+   %
+   \doifelsenothing{#3} % inherit from parent  ... needs checking
+     {\setupcurrentexternalfigures[#4,#5]}
+     {\ifcsname\??externalfigureinstance#3\endcsname
+        \pushmacro\grph_include_place
+        \def\grph_include_place[##1][##2][##3][##4]{\setupcurrentexternalfigures[##4,#4,#5]}%
+        \csname\??externalfigureinstance#3\endcsname
+        \popmacro\grph_include_place
+      \else
+        \setupcurrentexternalfigures[#4,#5]%
+      \fi}%
+   %
+   \the\everyexternalfigurechecks
+   %
+   \ctxlua{figures.push {
+        name       = "#2",
+        label      = "#1", % todo: \@eflabel
+        page       = "\externalfiguresparameter\c!page",
+        size       = "\externalfiguresparameter\c!size",
+        object     = "\externalfiguresparameter\c!object",
+        prefix     = "\externalfiguresparameter\c!prefix",
+        cache      = "\externalfiguresparameter\c!cache",
+        format     = "\externalfiguresparameter\c!method",
+        preset     = "\externalfiguresparameter\c!prefix",
+        controls   = "\externalfiguresparameter\c!controls",
+        resources  = "\externalfiguresparameter\c!resources",
+        preview    = "\externalfiguresparameter\c!preview",
+        display    = "\externalfiguresparameter\c!display",
+        mask       = "\externalfiguresparameter\c!mask",
+        conversion = "\externalfiguresparameter\c!conversion",
+        resolution = "\externalfiguresparameter\c!resolution",
+        color      = "\internalspotcolorparent{\externalfiguresparameter\c!color}", % hack is needed
+        ["repeat"] = "\externalfiguresparameter\c!repeat",
+        width      = "\externalfiguresparameter\c!width",  % can be crap
+        height     = "\externalfiguresparameter\c!height", % can be crap
+    } }%
+   \ctxlua{figures.identify()}%
+   % also mode: checkpresense only
+   \ifconditional\c_grph_include_test_only
+      \ifcase\figurestatus \else
+        \ctxlua{figures.check()}%
+        \ctxlua{figures.dummy()}%
+        \ctxlua{figures.scale()}%
+        \ctxlua{figures.done()}%
+      \fi
+      \grph_include_set_mode
+   \else
+      \ifcase\figurestatus
+        \ctxlua{figures.dummy()}%
+        \ctxlua{figures.scale()}%
+      \else
+        \ctxlua{figures.check()}%
+        \ctxlua{figures.include()}%
+        \ctxlua{figures.scale()}%
+      \fi
+      \ctxlua{figures.done()}%
+      \grph_include_set_mode
+      \grph_include_finalize
+   \fi
+   \ctxlua{figures.pop()}%
+   %
+   \dotagfigure
+   \naturalvbox attr \imageattribute 2 {\box\foundexternalfigure}%
+   \dostoptagged
+   \egroup}
 
-\def\resetfigurevariables {\the\everyexternalfigureresets}
-\def\checkfigurevariables {\the\everyexternalfigurechecks}
+%D Scaling:
 
-%D Historic feature:
+\let\dowithfigure\relax % name might change (into a proper hook)
 
-\appendtoks
-    \global\let\externalfigurelog\empty
-\to \everyexternalfigureresets
+\unexpanded\def\doscalefigure % used at lua end
+  {\global\setbox\foundexternalfigure\vbox{\scale[\v!figure]{\dowithfigure{\box\foundexternalfigure}}}}
 
-\let\runutilityfiletrue    \relax \let\runutilityfilefalse    \relax
-\let\consultutilityfiletrue\relax \let\consultutilityfilefalse\relax
+\definescale % some day we will inherit
+  [\v!figure]
+  [\c!hfactor  =\externalfiguresparameter\c!hfactor,
+   \c!wfactor  =\externalfiguresparameter\c!wfactor,
+   \c!factor   =\externalfiguresparameter\c!factor,
+   \c!maxwidth =\externalfiguresparameter\c!maxwidth ,
+   \c!maxheight=\externalfiguresparameter\c!maxheight,
+   \c!xscale   =\externalfiguresparameter\c!xscale,
+   \c!yscale   =\externalfiguresparameter\c!yscale,
+   \c!scale    =\externalfiguresparameter\c!scale,
+   \c!sx       =\externalfiguresparameter\c!sx,
+   \c!sy       =\externalfiguresparameter\c!sy,
+   \c!width    =\externalfiguresparameter\c!width,
+   \c!height   =\externalfiguresparameter\c!height,
+   \c!lines    =\externalfiguresparameter\c!lines]
 
 %D You can register additional suffixes with the following command:
 %D
@@ -57,19 +287,22 @@
 %D \stoptyping
 
 \unexpanded\def\definegraphictypesynonym
-  {\dodoubleargument\dodefinegraphictypesynonym}
+  {\dodoubleargument\grph_include_set_type_synonym}
 
-\def\dodefinegraphictypesynonym[#1][#2]%
+\def\grph_include_set_type_synonym[#1][#2]%
   {\ctxlua{figures.registersuffix("#1","#2")}}
 
 %D Additional paths can be installed with the regular setup command. The next
 %D macro picks up the list.
 
-\def\setfigurepathlist
-  {\ctxlua{figures.setpaths("\@@exlocation",\!!bs\@@exdirectory\!!es)}}
+\unexpanded\def\setfigurepathlist
+  {\ctxlua{figures.setpaths("\externalfiguresparameter\c!location",\!!bs\externalfiguresparameter\c!directory\!!es)}}
 
 %D Variables:
 
+\newbox \foundexternalfigure
+\newtoks\externalfigurepostprocessors
+
 \def\defaultfigurewidth  {8\lineheight}
 \def\defaultfigureheight {6\lineheight}
 
@@ -112,209 +345,95 @@
 \let\figurescalexscale   \figurexscale
 \let\figurescaleyscale   \figureyscale
 
+%D The main command:
+
+\unexpanded\def\externalfigure
+  {\dotripleempty\grph_include_set_type_synonym}
+
+\def\grph_include_set_type_synonym[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings]
+  {\bgroup % also catched #1 == empty ... scales nicer now
+   \ifcsname\??externalfigureinstance#1\endcsname
+     \doifassignmentelse{#2}
+       {\csname\??externalfigureinstance#1\endcsname[#2]}%
+       {\csname\??externalfigureinstance#1\endcsname[#3]}%
+   \else
+     \useexternalfigure[\s!dummy][#1][#2][#3]%
+     \csname\??externalfigureinstance\s!dummy\endcsname[]% [] is dummy arg 5
+   \fi
+   \egroup}
+
+%D Calculating:
+
+% \enabletrackers[figures.conversion]
+% \externalfigure[demo.svg]
+% \externalfigure[demo.svg][conversion=png]
+
+%D The following registers are used (if only to be downward compatible).
+
+\newconditional\c_grph_include_skip
+\newconditional\c_grph_include_test_only
+\newconditional\c_grph_include_level      \setfalse\c_grph_include_level  % true=background false=normal
+\newconditional\c_grph_include_flush      \settrue \c_grph_include_flush  % true=place      false=ignore
+
+\newsystemmode\v!figure
+
+\def\grph_include_set_mode
+  {\ifcase\figurestatus
+     \global\resetsystemmode\v!figure % todo, also: \v!resource
+   \else
+     \global\setsystemmode  \v!figure % todo, also: \v!resource
+   \fi}
+
 \appendtoks
-    \ctxlua { % figures.defaultwidth .. why not dimen
-        figures.setpaths("\@@exlocation","\@@exdirectory") ;
+    \ctxlua { % figures.defaultwidth .. maybe a dimen some day
+        figures.setpaths("\externalfiguresparameter\c!location","\externalfiguresparameter\c!directory") ;
         figures.defaultwidth  = \number\dimexpr\defaultfigurewidth \relax ;
         figures.defaultheight = \number\dimexpr\defaultfigureheight\relax ;
         figures.boxnumber     = \number\foundexternalfigure ;
     }%
 \to \everyexternalfigureresets
 
-%D In some situations we need to make sure that the figure related variables
-%D are reset. This is especially important when we are nesting. Is this still
-%D needed in \MKIV.
-
-\def\resetexternalfigures
-  {\let\@@efoption         \empty % \let\@@efprefix\empty
-   \let\@@efmaxwidth       \empty % \let\@@efcache \empty
-   \let\@@efmaxheight      \empty % \let\@@efframe \v!off
-   \let\@@efforegroundcolor\empty
-   \let\@@efcolor          \empty
-   \let\@@efconversion     \empty
-   \let\@@efbackground     \empty
-   \let\@@efresolution     \empty}
-
-\appendtoks \resetexternalfigures \to \everyoverlay
-\appendtoks \resetexternalfigures \to \everybeforepagebody % not really needed
-
-\def\resetfigureusersettings % if we use a command handler we can simply define a new instance
-  {%
-   \let\@@efmethod    \empty
-   \let\@@eflabel     \empty
-   \let\@@efsize      \empty
-   \let\@@efconversion\@@exconversion
-   \let\@@efresolution\@@exresolution
-   \let\@@efprefix    \@@exprefix
-   \let\@@efcache     \@@excache
-   \let\@@efpage      \!!zerocount
-   \let\@@efobject    \@@exobject
-   \let\@@efdisplay   \empty
-   \let\@@efmask      \empty
-   %
-   \let\@@efpreset    \v!yes
-   \let\@@efsplit     \empty
-   \let\@@efcolor     \empty
-   %
-   \let\@@efsymbol    \v!no
-   %
-   \let\@@efcontrols  \v!no
-   \let\@@efresources \empty
-   \let\@@efpreview   \v!no
-   \let\@@efrepeat    \v!no
-   %
-   \let\@@efforegroundcolor\empty
-   %
-   \let\@@efinteraction\@@exinteraction
-   %
-   \let\@@efhfactor   \empty
-   \let\@@efwfactor   \empty
-   \let\@@effactor    \empty
-   \let\@@efmaxwidth  \@@exmaxwidth
-   \let\@@efmaxheight \@@exmaxheight
-   \let\@@efxscale    \empty
-   \let\@@efyscale    \empty
-   \let\@@efscale     \empty
-   \let\@@efsx        \!!plusone
-   \let\@@efsy        \!!plusone
-   \let\@@efwidth     \empty
-   \let\@@efheight    \empty
-   \let\@@eflines     \empty
-   \let\@@efgrid      \empty}
-
-\resetfigureusersettings
-
-\appendtoks
-    \resetfigureusersettings
-\to \everyexternalfigureresets
-
-\def\checkfigureusersettings
-  {% old features
-   \doif\@@exoption\v!frame
-     {\let\@@efframe\v!on}%
-   \doif\@@exoption\v!empty
-     {\skipexternalfigurestrue
-      \let\@@efframe\v!off}%
-   \doifsomething\@@efwidth {\doifdimensionelse\@@efwidth {\edef\@@efwidth {\the\dimexpr\@@efwidth }}\donothing}%
-   \doifsomething\@@efheight{\doifdimensionelse\@@efheight{\edef\@@efheight{\the\dimexpr\@@efheight}}\donothing}%
-   % fake color in gray bitmaps, assumes that
-   % a transparent color is used
-   \doifsomething\@@efforegroundcolor
-     {\def\@@efbackground{\v!foreground,\v!color}%
-      \def\@@efbackgroundcolor{\@@efforegroundcolor}}}
-
 \appendtoks
-    \checkfigureusersettings
+    \edef\p_option{\externalfiguresparameter\c!option}%
+    \ifx\p_option\v!frame
+      \setfalse\c_grph_include_skip
+      \letexternalfiguresparameter\c!frame\v!on
+    \else\ifx\p_option\v!empty
+      \settrue\c_grph_include_skip
+      \letexternalfiguresparameter\c!frame\v!off
+    \else
+      \setfalse\c_grph_include_skip
+    \fi\fi
+    % fake color in gray bitmaps, assumes that
+    % a transparent color is used
+    \edef\p_foregroundcolor{\externalfiguresparameter\c!foregroundcolor}%
+    \ifx\p_foregroundcolor\empty \else
+        \setexternalfiguresparameter\c!background{\v!foreground,\v!color}%
+        \letexternalfiguresparameter\c!backgroundcolor\p_foregroundcolor
+    \fi
 \to \everyexternalfigurechecks
 
 %D Internal graphics are handled at the \TEX\ end:
 
-\def\doprocesstexlikefigure#1% retrofit into mkii
+\def\grph_include_process_tex#1%
   {\global\setbox\foundexternalfigure\vbox\framed
      [\c!strut=\v!no,\c!align=\v!normal,\c!frame=\v!off,
       \c!offset=\v!overlay,\c!width=\v!fit,\c!height=\v!fit]
      {\blank[\v!disable]#1\endgraf\removelastskip}} % disable should stay here!
 
-\def\doprocessmpslikefigure#1% retrofit into mkii
+\def\grph_include_process_mps#1% retrofit into mkii
   {\global\setbox\foundexternalfigure\vbox{\convertMPtoPDF{#1}11}}
 
-\def\doprocesscldlikefigure#1%
+\def\grph_include_process_cld#1%
   {\global\setbox\foundexternalfigure\vbox{\cldprocessfile{#1}}}
 
-\def\docheckfigurebuffer  #1{\doprocesstexlikefigure{\getbuffer[#1]}}
-\def\docheckfiguretex     #1{\doprocesstexlikefigure{\input{#1}}}
-\def\docheckfigurecld     #1{\doprocesscldlikefigure{#1}} % we can always add cldrun
-\def\docheckfiguremps     #1{\doprocessmpslikefigure{#1}}
-\def\docheckfiguremprun #1#2{\doprocesstexlikefigure{\useMPrun{#1}{#2}}}
-
-% \def\doscalefigure
-%   {\global\setbox\foundexternalfigure\vbox{\doscalebox\??ef{\dowithfigure{\box\foundexternalfigure}}}}
-
-\def\doscalefigure
-  {\global\setbox\foundexternalfigure\vbox{\scale[\v!figure]{\dowithfigure{\box\foundexternalfigure}}}}
-
-% quick hack: chaining \??ef via \s!parent happens when this is also a commandhandler
-
-\definescale
-  [\v!figure]
-  [\c!hfactor  =\@@efhfactor  ,
-   \c!wfactor  =\@@efwfactor  ,
-   \c!factor   =\@@effactor   ,
-   \c!maxwidth =\@@efmaxwidth ,
-   \c!maxheight=\@@efmaxheight,
-   \c!xscale   =\@@efxscale   ,
-   \c!yscale   =\@@efyscale   ,
-   \c!scale    =\@@efscale    ,
-   \c!sx       =\@@efsx       ,
-   \c!sy       =\@@efsy       ,
-   \c!width    =\@@efwidth    ,
-   \c!height   =\@@efheight   ,
-   \c!lines    =\@@eflines    ]
-
-\newconditional\testexternalfigureonly
-
-% \enabletrackers[figures.conversion]
-% \externalfigure[demo.svg]
-% \externalfigure[demo.svg][conversion=png]
+\unexpanded\def\docheckfigurebuffer  #1{\grph_include_process_tex{\getbuffer[#1]}}    % used al lua end
+\unexpanded\def\docheckfiguretex     #1{\grph_include_process_tex{\input{#1}}}        % used al lua end
+\unexpanded\def\docheckfigurecld     #1{\grph_include_process_cld{#1}}                % used al lua end
+\unexpanded\def\docheckfiguremps     #1{\grph_include_process_mps{#1}}                % used al lua end
+\unexpanded\def\docheckfiguremprun #1#2{\grph_include_process_tex{\useMPrun{#1}{#2}}} % used al lua end
 
-\unexpanded\def\calculateexternalfigure[#1][#2][#3][#4][#5][#6]% \cmd label filename parent_id preset current
-  {\dontcomplain
-   \restorecatcodes
-   \forgetall
-   \resetfigurevariables
-   \dosetefparameters{#4}{#5}{#6}%
-   \checkfigurevariables
-%    \begingroup
-%    \color[\@@efcolor]{\xdef\globcolorattr{\internalspotcolorname}}
-%    \endgroup
-   \ctxlua{figures.push {
-        name       = "#3",
-        label      = "#2", % todo: \@eflabel
-        page       = "\@@efpage",
-        size       = "\@@efsize",
-        object     = "\@@efobject",
-        prefix     = "\@@efprefix",
-        cache      = "\@@efcache",
-        format     = "\@@efmethod",
-        preset     = "\@@efprefix",
-        controls   = "\@@efcontrols",
-        resources  = "\@@efresources",
-        preview    = "\@@efpreview",
-        display    = "\@@efdisplay",
-        mask       = "\@@efmask",
-        conversion = "\@@efconversion",
-        resolution = "\@@efresolution",
-        color      = "\internalspotcolorparent\@@efcolor", % hack is needed
-        ["repeat"] = "\@@efrepeat",
-        width      = "\@@efwidth", % can be crap
-        height     = "\@@efheight", % can be crap
-    } }%
-   \ctxlua{figures.identify()}%
-   % also mode: checkpresense only
-   \ifconditional\testexternalfigureonly
-      \ifcase\figurestatus \else
-        \ctxlua{figures.check()}%
-        \ctxlua{figures.dummy()}%
-        \ctxlua{figures.scale()}%
-        \ctxlua{figures.done()}%
-      \fi
-      \signalexternalfigure
-   \else
-      \ifcase\figurestatus
-        \ctxlua{figures.dummy()}%
-        \ctxlua{figures.scale()}%
-      \else
-        \ctxlua{figures.check()}%
-        \ctxlua{figures.include()}%
-        \ctxlua{figures.scale()}%
-      \fi
-      \ctxlua{figures.done()}%
-      \signalexternalfigure
-      \finishexternalfigure
-   \fi
-   \ctxlua{figures.pop()}}
-
-\def\relocateexternalfigure % easier here than in lua
+\unexpanded\def\relocateexternalfigure % easier here than in lua
   {\global\setbox\foundexternalfigure\vbox to \ht\foundexternalfigure\bgroup
      \vss
      \ht\foundexternalfigure\zeropoint
@@ -324,33 +443,24 @@
      \egroup
    \egroup}
 
-\newsystemmode\v!figure
-
-\def\signalexternalfigure % global (dup call to status)
-  {\ifcase\figurestatus
-     \global\resetsystemmode\v!figure % todo, also: \v!resource
-   \else
-     \global\setsystemmode  \v!figure % todo, also: \v!resource
-   \fi}
-
 \unexpanded\def\startfoundexternalfigure#1#2% ht wd
   {\global\setbox\foundexternalfigure\vbox to #2\bgroup\vss\hbox to #1\bgroup}
 
 \unexpanded\def\stopfoundexternalfigure
   {\hss\egroup\egroup}
 
-\def\emptyfoundexternalfigure
+\unexpanded\def\emptyfoundexternalfigure % sort of obsolete
   {\startfoundexternalfigure\defaultfigurewidth\defaultfigureheight
    \stopfoundexternalfigure}
 
-\def\finishexternalfigure % here we use \figurevariables
+\def\grph_include_finalize
   {\global\setbox\foundexternalfigure\vbox
      {\ifcase\figurestatus
-        \let\@@efframe\v!on
+        \letexternalfiguresparameter\c!frame\v!on
       \fi
-      \ifconditional\externalfigureflush
-        \ifconditional\externalfigurelevel % probably background
-          \ifskipexternalfigures
+      \ifconditional\c_grph_include_flush
+        \ifconditional\c_grph_include_level % probably background
+          \ifconditional\c_grph_include_skip
             % nothing
             \fakebox\foundexternalfigure
           \else\ifcase\figurestatus
@@ -361,28 +471,29 @@
           \fi\fi
         \else
           \iftrialtypesetting \else \feedbackexternalfigure \fi
-          \settrue\externalfigurelevel
-          \ifskipexternalfigures
+          \settrue\c_grph_include_level
+          \ifconditional\c_grph_include_skip
             \ifcase\figurestatus
-              \externalfigurereplacement\figurelabel\figurefileoriginal{unknown}%
+              \grph_include_replacement\figurelabel\figurefileoriginal{unknown}%
             \else
-              \externalfigurereplacement\figurelabel\figurefullname{skipped}%
+              \grph_include_replacement\figurelabel\figurefullname{skipped}%
             \fi
           \else\ifcase\figurestatus
-            \externalfigurereplacement\figurelabel\figurefileoriginal{unknown}%
+            \grph_include_replacement\figurelabel\figurefileoriginal{unknown}%
           \else
             \the\externalfigurepostprocessors
-            \doifelse\@@efreset\v!yes
-              {\wd\foundexternalfigure\figurewidth
-               \ht\foundexternalfigure\figureheight
-               \dp\foundexternalfigure\zeropoint
-               \box\foundexternalfigure}
-              {\localframed % should also be applied to high res !
-                 [\??ef]
-                 [\c!offset=\v!overlay,
-                  \c!width=\figurewidth,
-                  \c!height=\figureheight]
-                 {\vfilll\box\foundexternalfigure}}%
+            \edef\p_reset{\externalfiguresparameter\c!reset}%
+            \ifx\p_reset\v!yes
+              \wd\foundexternalfigure\figurewidth
+              \ht\foundexternalfigure\figureheight
+              \dp\foundexternalfigure\zeropoint
+              \box\foundexternalfigure
+            \else
+              \letexternalfiguresparameter\c!offset\v!overlay
+              \letexternalfiguresparameter\c!width \figurewidth
+              \letexternalfiguresparameter\c!height\figureheight
+              \inheritedexternalfiguresframed{\vfilll\box\foundexternalfigure}%
+            \fi
           \fi\fi
         \fi
       \else
@@ -390,35 +501,17 @@
         \iftrialtypesetting \else \feedbackexternalfigure \fi
       \fi}}
 
-\ifx\externalfigurereplacement\undefined\let\externalfigurereplacement\gobblethreearguments\fi
-\ifx\externalfigureplaceholder\undefined\let\externalfigureplaceholder\gobblethreearguments\fi
+\let\feedbackexternalfigure\relax % hook
 
-\let\feedbackexternalfigure\relax % \gobblefourarguments
-\let\dowithfigure          \relax
+\unexpanded\def\getfiguredimensions
+  {\dodoubleempty\grph_include_get_dimensions}
 
-\def\getfiguredimensions
-  {\dodoubleempty\dogetfiguredimensions}
-
-\def\dogetfiguredimensions[#1][#2]%
+\def\grph_include_get_dimensions[#1][#2]%
   {\startnointerference
-     \settrue\testexternalfigureonly
+     \settrue\c_grph_include_test_only
      \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]%
    \stopnointerference}
 
-\let\getfiguredimensionsonly\getfiguredimensions
-
-% \unexpanded\def\doiffigureelse#1%
-%   {\getfiguredimensions[#1]% so data is available !
-%    \ifdim\figurewidth=\zeropoint % todo: \figurestatus
-%      \expandafter\secondoftwoarguments
-%    \else
-%      \expandafter\firstoftwoarguments
-%    \fi}
-
-% \unexpanded\def\doiffigureelse#1% just low level call
-%   {\getfiguredimensions[#1]% so data is available ! ... grouped so status is local
-%    \doifmodeelse{*\v!figure}\firstoftwoarguments\secondoftwoarguments} % mode is set global
-
 \unexpanded\def\doiffigureelse#1%
   {\getfiguredimensions[#1]% so data is available !
    \ifcase\figurestatus
@@ -427,74 +520,150 @@
      \expandafter\firstoftwoarguments
    \fi}
 
-\def\registerexternalfigure % no placement, handy for preprocessing
-  {\dotripleempty\doregisterexternalfigure}
+% No placement, handy for preprocessing:
 
-\def\doregisterexternalfigure[#1][#2][#3]%
+\unexpanded\def\registerexternalfigure
+  {\dotripleempty\grph_include_register}
+
+\def\grph_include_register[#1][#2][#3]%
   {\startnointerference
-     \testexternalfigureonly
-     \setfalse\externalfigureflush % == test ?
-     \externalfigure[#1][#2][#3]% or \doexternalfigure
+     \c_grph_include_test_only
+     \setfalse\c_grph_include_flush % == test ?
+     \externalfigure[#1][#2][#3]% or
      \externalfigure[#1][#2,\c!display=,\c!mask=,\c!object=\v!no]%
    \stopnointerference}
 
-% helpers (will be replaced when xforms are accessible at the lua end)
+% Helpers (will be replaced when xforms are accessible at the lua end)
 
-\def\dosetfigureobject#1%
+\unexpanded\def\dosetfigureobject#1%
   {\setobject{FIG}{#1}\vbox{\box\foundexternalfigure}}
 
-\def\doboxfigureobject#1%
+\unexpanded\def\doboxfigureobject#1%
   {\global\setbox\foundexternalfigure\vbox{\getobject{FIG}{#1}}} % probably one vbox too many
 
-% figurebases
+% Figure bases
 
-\def\usefigurebase[#1]%
+\unexpanded\def\usefigurebase[#1]%
   {\ctxlua{figures.bases.use("#1")}}
 
-\protect \endinput
+\appendtoks
+   \setfigurepathlist  % the path may be used elsewhere too (as in x-res-04)
+\to \everysetupexternalfigures
 
-% \startbuffer
-% \definecolor [blue]   [c=1,m=.38,y=0,k=.64]
-% \definecolor [yellow] [c=0,m=.28,y=1,k=.06]
-%
-% \definespotcolor [blue-100]   [blue]   [p=1]
-% \definespotcolor [yellow-100] [yellow] [p=1]
-%
-% \definemultitonecolor [combicolor]   [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]
-%
-% \definemultitonecolor [combicolor-b] [blue=1]   [c=1,m=.38,y=0,k=.64] % force multitone
-% \definemultitonecolor [combicolor-y] [yellow=1] [c=0,m=.28,y=1,k=.06] % force multitone
-%
-% \useexternalfigure[demo-a][mill.png]     [object=no,width=.2\textwidth]
-% \useexternalfigure[demo-b][hacker-bw.jpg][object=no,width=.2\textwidth]
-%
-% \startbaselinecorrection \startcombination[4*1]
-%   {\externalfigure[demo-a]}                     {no color}
-%   {\externalfigure[demo-a][color=combicolor]}   {indexed duotone}
-%   {\externalfigure[demo-a][color=combicolor-b]} {spot color}
-%   {\externalfigure[demo-a][color=combicolor-y]} {spot color}
-% \stopcombination \stopbaselinecorrection
-%
-% \startbaselinecorrection \startcombination[4*1]
-%   {\externalfigure[demo-b]}                     {no color}
-%   {\externalfigure[demo-b][color=combicolor]}   {indexed duotone}
-%   {\externalfigure[demo-b][color=combicolor-b]} {spot color}
-%   {\externalfigure[demo-b][color=combicolor-y]} {spot color}
-% \stopcombination \stopbaselinecorrection
-%
-% \startbaselinecorrection \startcombination[4*1]
-%   {\externalfigure[demo-a]}                     {no color}
-%   {\externalfigure[demo-a][color=combicolor]}   {indexed duotone}
-%   {\externalfigure[demo-a][color=blue-100]}     {spot color}
-%   {\externalfigure[demo-a][color=yellow-100]}   {spot color}
-% \stopcombination \stopbaselinecorrection
-%
-% \startbaselinecorrection \startcombination[4*1]
-%   {\externalfigure[demo-b]}                     {no color}
-%   {\externalfigure[demo-b][color=combicolor]}   {indexed duotone}
-%   {\externalfigure[demo-b][color=blue-100]}     {spot color}
-%   {\externalfigure[demo-b][color=yellow-100]}   {spot color}
-% \stopcombination \stopbaselinecorrection
-% \stopbuffer
-%
-% \getbuffer \typebuffer
+\appendtoks
+    \ctxcommand{setfigurelookuporder("\externalfiguresparameter\c!order")}%
+\to \everysetupexternalfigures
+
+\definecolor[missingfigurecolor][s=.8]
+
+\def\grph_include_replacement#1#2#3%
+  {\bgroup
+   \letexternalfiguresparameter\c!width\figurewidth
+   \letexternalfiguresparameter\c!height\figureheight
+   \letexternalfiguresparameter\c!background\v!color
+   \setexternalfiguresparameter\c!backgroundcolor{missingfigurecolor}%
+   \inheritedexternalfiguresframed
+     {\tt\tfxx \nohyphens
+      name:  \expanded{\verbatimstring{#1}}\\%
+      file:  \expanded{\verbatimstring{#2}}\\%
+      state: \expanded{\verbatimstring{#3}}}%
+   \egroup}
+
+% \def\grph_include_placeholder#1#2#3%
+%   {\bgroup
+%    \setexternalfiguresparameter\c!width{#2}%
+%    \setexternalfiguresparameter\c!height{#3}%
+%    \letexternalfiguresparameter\c!frame\v!on
+%    \inheritedexternalfiguresframed
+%      {\tt\tfxx \nohyphens
+%         name:  \expanded{\verbatimstring{#1}}\\%
+%         state: \expanded{\verbatimstring{placeholder}}}%
+%    \egroup}
+
+% maybe setuphandler
+
+\newconditional\c_grph_include_in_collection
+
+\newdimen\d_grph_include_collection_minwidth
+\newdimen\d_grph_include_collection_maxwidth
+\newdimen\d_grph_include_collection_minheight
+\newdimen\d_grph_include_collection_maxheight
+
+\def\grph_include_analyze_collection[#1][#2]%
+  {\ifconditional\c_grph_include_in_collection
+      \setfalse\c_grph_include_in_collection
+      \getfiguredimensions[#1][#2]%
+      \settrue\c_grph_include_in_collection
+      \scratchdimen\naturalfigurewidth
+      \ifdim\scratchdimen>\d_grph_include_collection_maxwidth  \d_grph_include_collection_maxwidth \scratchdimen \fi
+      \ifdim\scratchdimen<\d_grph_include_collection_minwidth  \d_grph_include_collection_minwidth \scratchdimen \fi
+      \scratchdimen\naturalfigureheight
+      \ifdim\scratchdimen>\d_grph_include_collection_maxheight \d_grph_include_collection_maxheight\scratchdimen \fi
+      \ifdim\scratchdimen<\d_grph_include_collection_minheight \d_grph_include_collection_minheight\scratchdimen \fi
+   \fi}
+
+\unexpanded\def\startexternalfigurecollection[#1]%
+  {\begingroup
+   \def\currentexternalfigurecollection{#1}%
+   \settrue\c_grph_include_in_collection
+   \d_grph_include_collection_minwidth \maxdimen
+   \d_grph_include_collection_maxwidth \zeropoint
+   \d_grph_include_collection_minheight\maxdimen
+   \d_grph_include_collection_maxheight\zeropoint}
+
+\unexpanded\def\stopexternalfigurecollection
+  {\setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!minwidth }{\the\d_grph_include_collection_minwidth }%
+   \setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!maxwidth }{\the\d_grph_include_collection_maxwidth }%
+   \setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!minheight}{\the\d_grph_include_collection_minheight}%
+   \setxvalue{\??externalfigurecollection\currentexternalfigurecollection:\c!maxheight}{\the\d_grph_include_collection_maxheight}%
+   \endgroup}
+
+\def\externalfigurecollectionparameter#1#2%
+  {\csname
+     \ifcsname\??externalfigurecollection#1:#2\endcsname
+       \??externalfigurecollection#1:#2%
+     \else
+       \s!empty
+     \fi
+   \endcsname}
+
+\def\externalfigurecollectionminwidth #1{\externalfigurecollectionparameter{#1}\c!minwidth }
+\def\externalfigurecollectionmaxwidth #1{\externalfigurecollectionparameter{#1}\c!maxwidth }
+\def\externalfigurecollectionminheight#1{\externalfigurecollectionparameter{#1}\c!minheight}
+\def\externalfigurecollectionmaxheight#1{\externalfigurecollectionparameter{#1}\c!maxheight}
+
+\let\efcparameter\externalfigurecollectionparameter % still needed ?
+\let\efcminwidth \externalfigurecollectionminwidth  % still needed ?
+\let\efcmaxwidth \externalfigurecollectionmaxwidth  % still needed ?
+\let\efcminheight\externalfigurecollectionminheight % still needed ?
+\let\efcmaxheight\externalfigurecollectionmaxheight % still needed ?
+
+% \startexternalfigurecollection[name]
+%     \useexternalfigure[cow] [cow.pdf]
+%     \useexternalfigure[mill][mill.png]
+% \stopexternalfigurecollection
+% \starttext
+% \bTABLE
+%     \bTR
+%         \bTD \externalfigure[cow] [height=\externalfigurecollectionmaxheight{name}] \eTD
+%         \bTD \externalfigure[mill][height=\externalfigurecollectionmaxheight{name}] \eTD
+%     \eTR
+% \eTABLE
+% \stoptext
+
+\unexpanded\def\showexternalfigures % maybe run time command is better, but no core-run, unless figs-run ...
+  {%\writestatus\m!system{for \string\showexternalfigures\space see \truefilename{x-res-20}.tex}
+   \usemodule[res-20]%
+   \showexternalfigures} % so for the moment we do it this way
+
+\unexpanded\def\overlayfigure#1%
+  {\externalfigure[#1][\c!width=\overlaywidth,\c!height=\overlayheight]}
+
+% Bonus:
+
+\useexternalfigure
+  [buffer]
+  [\jobname.buffer]
+  [\c!object=\v!no]
+
+\protect \endinput
diff --git a/tex/context/base/l-number.lua b/tex/context/base/l-number.lua
index b1ffb9ca9..301380eee 100644
--- a/tex/context/base/l-number.lua
+++ b/tex/context/base/l-number.lua
@@ -72,11 +72,11 @@ function number.hasbit(x, p) -- typical call: if hasbit(x, bit(3)) then ...
 end
 
 function number.setbit(x, p)
-    return hasbit(x, p) and x or x + p
+    return (x % (p + p) >= p) and x or x + p
 end
 
 function number.clearbit(x, p)
-    return hasbit(x, p) and x - p or x
+    return (x % (p + p) >= p) and x - p or x
 end
 
 --~ function number.tobitstring(n)
diff --git a/tex/context/base/m-database.mkiv b/tex/context/base/m-database.mkiv
index cef0aa815..91da78879 100644
--- a/tex/context/base/m-database.mkiv
+++ b/tex/context/base/m-database.mkiv
@@ -17,11 +17,6 @@
 
 \unprotect
 
-\def\c!first       {first}
-\def\c!last        {last}
-\def\c!quotechar   {quotechar}
-\def\c!commentchar {commentchar}
-
 \definenamespace
   [db]
   [type=module,
diff --git a/tex/context/base/m-spreadsheet.mkiv b/tex/context/base/m-spreadsheet.mkiv
index f2b042d09..c21e10f1d 100644
--- a/tex/context/base/m-spreadsheet.mkiv
+++ b/tex/context/base/m-spreadsheet.mkiv
@@ -17,9 +17,6 @@
 
 \unprotect
 
-\ifdefined\c!comma  \else \def\c!comma {comma}  \fi
-\ifdefined\c!period \else \def\c!period{period} \fi
-
 % todo: get(...) set(..) ctx(...)
 
 \installcorenamespace{spreadsheet}
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index 868fa7f5c..9a8dbef25 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -27,14 +27,6 @@
 
 \unprotect
 
-\ifdefined\v!autopunctuation \else \def\v!autopunctuation{autopunctuation} \fi
-\ifdefined\v!integral        \else \def\v!integral       {integral}        \fi
-
-\def\s!lcgreek {lcgreek}
-\def\s!ucgreek {ucgreek}
-\def\s!italics {italics}
-\def\s!integral{integral}
-
 %D We move these definitions into the format:
 
 % test  [[\char948 \cldcontext{utf.char(948)}]]
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index aae94e835..dfad1fb8b 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -290,23 +290,23 @@
       \ifthirdargument
         \the#6% predefine
         \edef#8{##2}%
-        \expandafter\def\csname#1#4:\s!parent\endcsname{#1##2}%
+        \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}% was \def
         \mult_interfaces_get_parameters{#1#4:}[##3]%
       \else\ifsecondargument
         \the#6% predefine
         \expandafter\mult_check_for_assignment_indeed\detokenize{##2}=@@\_end_
         \ifassignment
           \let#8\empty
-          \expandafter\def\csname#1#4:\s!parent\endcsname{#3}%
+          \expandafter\def\csname#1#4:\s!parent\endcsname{#3}% maybe \edef is more efficient
           \mult_interfaces_get_parameters{#1#4:}[##2]%
         \else
           \edef#8{##2}%
-          \expandafter\def\csname#1#4:\s!parent\endcsname{#1##2}%
+          \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}% was \def
         \fi
       \else
         \the#6% predefine
         \let#8\empty
-        \expandafter\def\csname#1#4:\s!parent\endcsname{#3}%
+        \expandafter\def\csname#1#4:\s!parent\endcsname{#3}% maybe \edef is more efficient
       \fi\fi
       \the#7%
       \let#4#9}}
diff --git a/tex/context/base/mult-chk.mkiv b/tex/context/base/mult-chk.mkiv
index 9260d2040..3b58a19fb 100644
--- a/tex/context/base/mult-chk.mkiv
+++ b/tex/context/base/mult-chk.mkiv
@@ -35,8 +35,8 @@
 
 \registerctxluafile{mult-chk}{1.001}
 
-\def\setvalidparameterkeys{\dodoubleargument\mult_checkers_set_valid_parameter_keys}
-\def\addvalidparameterkeys{\dodoubleargument\mult_checkers_add_valid_parameter_keys}
+\unexpanded\def\setvalidparameterkeys{\dodoubleargument\mult_checkers_set_valid_parameter_keys}
+\unexpanded\def\addvalidparameterkeys{\dodoubleargument\mult_checkers_add_valid_parameter_keys}
 
 \def\mult_checkers_set_valid_parameter_keys[#1][#2]{\ctxlua{interfaces.setvalidkeys("#1",\!!bs#2\!!es)}}
 \def\mult_checkers_add_valid_parameter_keys[#1][#2]{\ctxlua{interfaces.addvalidkeys("#1",\!!bs#2\!!es)}}
@@ -62,11 +62,11 @@
    \fi{#3}#5}
 
 \def\mult_checkers_get_checked_parameters_nop_indeed#1#2]%
-  {\def\p!dogetparameter{\p!doassign#1}%
+  {\def\p!dogetparameter{\p!doassign#1}% will change
    \xprocesscommaitem#2,],\@relax@}
 
-\def\disablecheckparameters{\let\getcheckedparameters\mult_checkers_get_checked_parameters_nop}
-\def\enablecheckparameters {\let\getcheckedparameters\mult_checkers_get_checked_parameters_yes}
+\unexpanded\def\disablecheckparameters{\let\getcheckedparameters\mult_checkers_get_checked_parameters_nop}
+\unexpanded\def\enablecheckparameters {\let\getcheckedparameters\mult_checkers_get_checked_parameters_yes}
 
 \disablecheckparameters
 
diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index f6f50ae72..68931d936 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -13,21 +13,54 @@
 
 \unprotect
 
-\setvalue{\??mi   :czech}{cs}
-\setvalue{\??mi  :german}{de}
-\setvalue{\??mi :english}{en}
-\setvalue{\??mi  :french}{fr}
-\setvalue{\??mi :italian}{it}
-\setvalue{\??mi   :dutch}{nl}
-\setvalue{\??mi :persian}{pe}
-\setvalue{\??mi:romanian}{ro}
-
-\def\userinterfacetag{\ifcsname\??mi:\currentinterface\endcsname\csname\??mi:\currentinterface\endcsname\else en\fi}
-\def\userresponsestag{\ifcsname\??mi:\currentresponses\endcsname\csname\??mi:\currentresponses\endcsname\else en\fi}
+\installcorenamespace{multilingual}
+
+\setvalue{\??multilingual    czech}{cs}
+\setvalue{\??multilingual   german}{de}
+\setvalue{\??multilingual  english}{en}
+\setvalue{\??multilingual   french}{fr}
+\setvalue{\??multilingual  italian}{it}
+\setvalue{\??multilingual    dutch}{nl}
+\setvalue{\??multilingual  persian}{pe}
+\setvalue{\??multilingual romanian}{ro}
+
+\def\userinterfacetag{\ifcsname\??multilingual\currentinterface\endcsname\csname\??multilingual\currentinterface\endcsname\else en\fi}
+\def\userresponsestag{\ifcsname\??multilingual\currentresponses\endcsname\csname\??multilingual\currentresponses\endcsname\else en\fi}
 
 % \input mult-\userinterfacetag  \relax
 % \input mult-m\userresponsestag \relax
 
 \ctxlua{interfaces.setuserinterface("\userinterfacetag","\userresponsestag")}
 
+% start todo:
+
+\def\c!renderingsetup {renderingsetup}
+\def\c!filler         {filler}
+\def\c!resources      {resources}
+\def\c!first          {first}
+\def\c!last           {last}
+\def\c!quotechar      {quotechar}
+\def\c!commentchar    {commentchar}
+\def\c!symbolcommand  {symbolcommand}
+\def\c!xmlsetup       {xmlsetup}
+\def\c!comma          {comma}
+\def\c!period         {period}
+\def\c!monthconversion{monthconversion}
+
+\def\v!notation       {notation}
+\def\v!endnote        {endnote}
+\def\v!interactive    {interactive}
+\def\v!autopunctuation{autopunctuation}
+\def\v!integral       {integral}
+\def\v!shiftup        {shiftup}
+\def\v!shiftdown      {shiftdown}
+\def\v!construction   {construction}
+
+\def\s!lcgreek        {lcgreek}
+\def\s!ucgreek        {ucgreek}
+\def\s!italics        {italics}
+\def\s!integral       {integral}
+
+% stop todo
+
 \protect \endinput
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index 586b54813..76fb08141 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -136,13 +136,13 @@ return {
         --
         "then",
         --
-        "donothing", "dontcomplain",
+        "donothing", "dontcomplain", "forgetall",
         --
         "donetrue", "donefalse",
         --
         "htdp",
         "unvoidbox",
-        "vfilll",
+        "hfilll", "vfilll",
         --
         "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha",
         --
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index bb52dc518..ab4931119 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -505,9 +505,6 @@
 \definesystemvariable {lu}   % LUacode
 \definesystemvariable {ma}   % MargeAchtergrond
 \definesystemvariable {mc}   % MultiColumn
-\definesystemvariable {mi}   % MultilingualInterface
-\definesystemvariable {ml}   % MultilingualLabel
-\definesystemvariable {mm}   % MultilingualMath
 \definesystemvariable {mt}   % inline MaTh
 \definesystemvariable {mt}   % multi column (!!! double usage)
 \definesystemvariable {mo}   % Math Options
diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua
index 43624adfd..139f25046 100644
--- a/tex/context/base/node-aux.lua
+++ b/tex/context/base/node-aux.lua
@@ -342,7 +342,7 @@ end
 
 nodes.locate =  locate
 
-function nodes.concat(list) -- no slide !
+function nodes.concat(list)
     local head, tail
     for i=1,#list do
         local li = list[i]
@@ -351,10 +351,10 @@ function nodes.concat(list) -- no slide !
         elseif head then
             tail.next = li
             li.prev = tail
-            tail = li
+            tail = li.next and slide_nodes(li) or li
         else
             head = li
-            tail = li
+            tail = li.next and slide_nodes(li) or li
         end
     end
     return head, tail
diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua
index d64c24479..dadbf80d3 100644
--- a/tex/context/base/node-fin.lua
+++ b/tex/context/base/node-fin.lua
@@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['node-fin'] = {
 }
 
 -- this module is being reconstructed
+-- local functions, only slightly slower
 
 local next, type, format = next, type, string.format
 
@@ -194,6 +195,8 @@ function states.initialize(namespace,attribute,head)
     if nsstep then
         nsbegin      = namespace.resolve_begin
         nsend        = namespace.resolve_end
+        nspush       = namespace.push
+        nspop        = namespace.pop
     end
 end
 
@@ -213,81 +216,167 @@ function states.finalize(namespace,attribute,head) -- is this one ok?
     return head, false, false
 end
 
+-- disc nodes can be ignored
+-- we need to deal with literals too (reset as well as oval)
+-- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then
+
+-- local function process(namespace,attribute,head,inheritance,default) -- one attribute
+--     local stack, done = head, false
+--     while stack do
+--         local id = stack.id
+--         if id == glyph_code or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+--             local c = has_attribute(stack,attribute)
+--             if c then
+--                 if default and c == inheritance then
+--                     if current ~= default then
+--                         head = insert_node_before(head,stack,copy_node(nsdata[default]))
+--                         current = default
+--                         done = true
+--                     end
+--                 elseif current ~= c then
+--                     head = insert_node_before(head,stack,copy_node(nsdata[c]))
+--                     current = c
+--                     done = true
+--                 end
+--                 -- here ? compare selective
+--                 if id == glue_code then --leader
+--                     -- same as *list
+--                     local content = stack.leader
+--                     if content then
+--                         local savedcurrent = current
+--                         local ci = content.id
+--                         if ci == hlist_code or ci == vlist_code then
+--                             -- else we reset inside a box unneeded, okay, the downside is
+--                             -- that we trigger color in each repeated box, so there is room
+--                             -- for improvement here
+--                             current = 0
+--                         end
+--                         local ok = false
+--                         if nstrigger and has_attribute(stack,nstrigger) then
+--                             local outer = has_attribute(stack,attribute)
+--                             if outer ~= inheritance then
+--                                 stack.leader, ok = process(namespace,attribute,content,inheritance,outer)
+--                             else
+--                                 stack.leader, ok = process(namespace,attribute,content,inheritance,default)
+--                             end
+--                         else
+--                             stack.leader, ok = process(namespace,attribute,content,inheritance,default)
+--                         end
+--                         current = savedcurrent
+--                         done = done or ok
+--                     end
+--                 end
+--             elseif default and inheritance then
+--                 if current ~= default then
+--                     head = insert_node_before(head,stack,copy_node(nsdata[default]))
+--                     current = default
+--                     done = true
+--                 end
+--             elseif current > 0 then
+--                 head = insert_node_before(head,stack,copy_node(nsnone))
+--                 current = 0
+--                 done = true
+--             end
+--         elseif id == hlist_code or id == vlist_code then
+--             local content = stack.list
+--             if content then
+--                 local ok = false
+--                 if nstrigger and has_attribute(stack,nstrigger) then
+--                     local outer = has_attribute(stack,attribute)
+--                     if outer ~= inheritance then
+--                         stack.list, ok = process(namespace,attribute,content,inheritance,outer)
+--                     else
+--                         stack.list, ok = process(namespace,attribute,content,inheritance,default)
+--                     end
+--                 else
+--                     stack.list, ok = process(namespace,attribute,content,inheritance,default)
+--                 end
+--                 done = done or ok
+--             end
+--         end
+--         stack = stack.next
+--     end
+--     return head, done
+-- end
+
 local function process(namespace,attribute,head,inheritance,default) -- one attribute
     local stack, done = head, false
-    while stack do
-        local id = stack.id
-        -- we need to deal with literals too (reset as well as oval)
-        -- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
-        if id == glyph_code -- or id == disc_code
-                or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
-            local c = has_attribute(stack,attribute)
-            if c then
-                if default and c == inheritance then
-                    if current ~= default then
-                        head = insert_node_before(head,stack,copy_node(nsdata[default]))
-                        current = default
-                        done = true
-                    end
-                elseif current ~= c then
-                    head = insert_node_before(head,stack,copy_node(nsdata[c]))
-                    current = c
-                    done = true
-                end
-                -- here ? compare selective
-                if id == glue_code then --leader
-                    -- same as *list
-                    local content = stack.leader
-                    if content then
-                        local savedcurrent = current
-                        local ci = content.id
-                        if ci == hlist_code or ci == vlist_code then
-                            -- else we reset inside a box unneeded, okay, the downside is
-                            -- that we trigger color in each repeated box, so there is room
-                            -- for improvement here
-                            current = 0
-                        end
-                        local ok = false
-                        if nstrigger and has_attribute(stack,nstrigger) then
-                            local outer = has_attribute(stack,attribute)
-                            if outer ~= inheritance then
-                                stack.leader, ok = process(namespace,attribute,content,inheritance,outer)
-                            else
-                                stack.leader, ok = process(namespace,attribute,content,inheritance,default)
-                            end
-                        else
-                            stack.leader, ok = process(namespace,attribute,content,inheritance,default)
-                        end
-                        current = savedcurrent
-                        done = done or ok
-                    end
-                end
-            elseif default and inheritance then
+
+    local function check()
+        local c = has_attribute(stack,attribute)
+        if c then
+            if default and c == inheritance then
                 if current ~= default then
                     head = insert_node_before(head,stack,copy_node(nsdata[default]))
                     current = default
                     done = true
                 end
-            elseif current > 0 then
-                head = insert_node_before(head,stack,copy_node(nsnone))
-                current = 0
+            elseif current ~= c then
+                head = insert_node_before(head,stack,copy_node(nsdata[c]))
+                current = c
                 done = true
             end
+        elseif default and inheritance then
+            if current ~= default then
+                head = insert_node_before(head,stack,copy_node(nsdata[default]))
+                current = default
+                done = true
+            end
+        elseif current > 0 then
+            head = insert_node_before(head,stack,copy_node(nsnone))
+            current = 0
+            done = true
+        end
+        return c
+    end
+
+    local function nested(content)
+        if nstrigger and has_attribute(stack,nstrigger) then
+            local outer = has_attribute(stack,attribute)
+            if outer ~= inheritance then
+                return process(namespace,attribute,content,inheritance,outer)
+            else
+                return process(namespace,attribute,content,inheritance,default)
+            end
+        else
+            return process(namespace,attribute,content,inheritance,default)
+        end
+    end
+
+    while stack do
+        local id = stack.id
+        if id == glyph_code then
+            check()
+        elseif id == rule_code then
+            if stack.width ~= 0 then
+                check()
+            end
+        elseif id == glue_code then
+            local content = stack.leader
+            if content and check() then
+                local savedcurrent = current
+                local ci = content.id
+                if ci == hlist_code or ci == vlist_code then
+                    -- else we reset inside a box unneeded, okay, the downside is
+                    -- that we trigger color in each repeated box, so there is room
+                    -- for improvement here
+                    current = 0
+                end
+
+                local ok = false
+                stack.leader, ok = nested(content)
+                done = done or ok
+
+                current = savedcurrent
+            end
         elseif id == hlist_code or id == vlist_code then
             local content = stack.list
             if content then
+
                 local ok = false
-                if nstrigger and has_attribute(stack,nstrigger) then
-                    local outer = has_attribute(stack,attribute)
-                    if outer ~= inheritance then
-                        stack.list, ok = process(namespace,attribute,content,inheritance,outer)
-                    else
-                        stack.list, ok = process(namespace,attribute,content,inheritance,default)
-                    end
-                else
-                    stack.list, ok = process(namespace,attribute,content,inheritance,default)
-                end
+                stack.list, ok = nested(content)
                 done = done or ok
+
             end
         end
         stack = stack.next
@@ -303,86 +392,185 @@ states.process = process
 -- state changes while the main state stays the same (like two glyphs following
 -- each other with the same color but different color spaces e.g. \showcolor)
 
+-- local function selective(namespace,attribute,head,inheritance,default) -- two attributes
+--     local stack, done = head, false
+--     while stack do
+--         local id = stack.id
+--         -- we need to deal with literals too (reset as well as oval)
+--         -- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+--         if id == glyph_code -- or id == disc_code
+--                 or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+--             local c = has_attribute(stack,attribute)
+--             if c then
+--                 if default and c == inheritance then
+--                     if current ~= default then
+--                         local data = nsdata[default]
+--                         head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
+--                         current = default
+--                         done = true
+--                     end
+--                 else
+--                     local s = has_attribute(stack,nsselector)
+--                     if current ~= c or current_selector ~= s then
+--                         local data = nsdata[c]
+--                         head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
+--                         current = c
+--                         current_selector = s
+--                         done = true
+--                     end
+--                 end
+--             elseif default and inheritance then
+--                 if current ~= default then
+--                     local data = nsdata[default]
+--                     head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
+--                     current = default
+--                     done = true
+--                 end
+--             elseif current > 0 then
+--                 head = insert_node_before(head,stack,copy_node(nsnone))
+--                 current, current_selector, done = 0, 0, true
+--             end
+--             if id == glue_code then -- leader
+--                 -- same as *list
+--                 local content = stack.leader
+--                 if content then
+--                     local savedcurrent = current
+--                     local ci = content.id
+--                     if ci == hlist_code or ci == vlist_code then
+--                         -- else we reset inside a box unneeded, okay, the downside is
+--                         -- that we trigger color in each repeated box, so there is room
+--                         -- for improvement here
+--                         current = 0
+--                     end
+--                     local ok = false
+--                     if nstrigger and has_attribute(stack,nstrigger) then
+--                         local outer = has_attribute(stack,attribute)
+--                         if outer ~= inheritance then
+--                             stack.leader, ok = selective(namespace,attribute,content,inheritance,outer)
+--                         else
+--                             stack.leader, ok = selective(namespace,attribute,content,inheritance,default)
+--                         end
+--                     else
+--                         stack.leader, ok = selective(namespace,attribute,content,inheritance,default)
+--                     end
+--                     current = savedcurrent
+--                     done = done or ok
+--                 end
+--             end
+--         elseif id == hlist_code or id == vlist_code then
+--             local content = stack.list
+--             if content then
+--                 local ok = false
+--                 if nstrigger and has_attribute(stack,nstrigger) then
+--                     local outer = has_attribute(stack,attribute)
+--                     if outer ~= inheritance then
+--                         stack.list, ok = selective(namespace,attribute,content,inheritance,outer)
+--                     else
+--                         stack.list, ok = selective(namespace,attribute,content,inheritance,default)
+--                     end
+--                 else
+--                     stack.list, ok = selective(namespace,attribute,content,inheritance,default)
+--                 end
+--                 done = done or ok
+--             end
+--         end
+--         stack = stack.next
+--     end
+--     return head, done
+-- end
+
 local function selective(namespace,attribute,head,inheritance,default) -- two attributes
     local stack, done = head, false
-    while stack do
-        local id = stack.id
-        -- we need to deal with literals too (reset as well as oval)
-        -- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
-        if id == glyph_code -- or id == disc_code
-                or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
-            local c = has_attribute(stack,attribute)
-            if c then
-                if default and c == inheritance then
-                    if current ~= default then
-                        local data = nsdata[default]
-                        head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
-                        current = default
-                        done = true
-                    end
-                else
-                    local s = has_attribute(stack,nsselector)
-                    if current ~= c or current_selector ~= s then
-                        local data = nsdata[c]
-                        head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
-                        current = c
-                        current_selector = s
-                        done = true
-                    end
-                end
-            elseif default and inheritance then
+
+    local function check()
+        local c = has_attribute(stack,attribute)
+        if c then
+            if default and c == inheritance then
                 if current ~= default then
                     local data = nsdata[default]
                     head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
                     current = default
                     done = true
                 end
-            elseif current > 0 then
-                head = insert_node_before(head,stack,copy_node(nsnone))
-                current, current_selector, done = 0, 0, true
+            else
+                local s = has_attribute(stack,nsselector)
+                if current ~= c or current_selector ~= s then
+                    local data = nsdata[c]
+                    head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
+                    current = c
+                    current_selector = s
+                    done = true
+                end
             end
-            if id == glue_code then -- leader
-                -- same as *list
-                local content = stack.leader
-                if content then
-                    local savedcurrent = current
-                    local ci = content.id
-                    if ci == hlist_code or ci == vlist_code then
-                        -- else we reset inside a box unneeded, okay, the downside is
-                        -- that we trigger color in each repeated box, so there is room
-                        -- for improvement here
-                        current = 0
-                    end
-                    local ok = false
-                    if nstrigger and has_attribute(stack,nstrigger) then
-                        local outer = has_attribute(stack,attribute)
-                        if outer ~= inheritance then
-                            stack.leader, ok = selective(namespace,attribute,content,inheritance,outer)
-                        else
-                            stack.leader, ok = selective(namespace,attribute,content,inheritance,default)
-                        end
-                    else
-                        stack.leader, ok = selective(namespace,attribute,content,inheritance,default)
-                    end
-                    current = savedcurrent
-                    done = done or ok
+        elseif default and inheritance then
+            if current ~= default then
+                local data = nsdata[default]
+                head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
+                current = default
+                done = true
+            end
+        elseif current > 0 then
+            head = insert_node_before(head,stack,copy_node(nsnone))
+            current, current_selector, done = 0, 0, true
+        end
+        return c
+    end
+
+    local function nested(content)
+        if nstrigger and has_attribute(stack,nstrigger) then
+            local outer = has_attribute(stack,attribute)
+            if outer ~= inheritance then
+                return selective(namespace,attribute,content,inheritance,outer)
+            else
+                return selective(namespace,attribute,content,inheritance,default)
+            end
+        else
+            return selective(namespace,attribute,content,inheritance,default)
+        end
+    end
+
+    while stack do
+        local id = stack.id
+        if id == glyph_code then
+            check()
+        elseif id == rule_code then
+            if stack.width ~= 0 then
+                check()
+            end
+        elseif id == glue_code then
+            local content = stack.leader
+            if content and check() then
+                local savedcurrent = current
+                local ci = content.id
+                if ci == hlist_code or ci == vlist_code then
+                    -- else we reset inside a box unneeded, okay, the downside is
+                    -- that we trigger color in each repeated box, so there is room
+                    -- for improvement here
+                    current = 0
                 end
+
+                local ok = false
+                stack.leader, ok = nested(content)
+                done = done or ok
+
+                current = savedcurrent
             end
         elseif id == hlist_code or id == vlist_code then
             local content = stack.list
             if content then
+
                 local ok = false
-                if nstrigger and has_attribute(stack,nstrigger) then
-                    local outer = has_attribute(stack,attribute)
-                    if outer ~= inheritance then
-                        stack.list, ok = selective(namespace,attribute,content,inheritance,outer)
-                    else
-                        stack.list, ok = selective(namespace,attribute,content,inheritance,default)
-                    end
-                else
-                    stack.list, ok = selective(namespace,attribute,content,inheritance,default)
-                end
+                stack.list, ok = nested(content)
                 done = done or ok
+
+             -- nicer:
+             --
+             -- local content, ok = nested(content)
+             -- if ok then
+             --     stack.leader = content
+             --     done = true
+             -- end
+
             end
         end
         stack = stack.next
@@ -390,6 +578,7 @@ local function selective(namespace,attribute,head,inheritance,default) -- two at
     return head, done
 end
 
+
 states.selective = selective
 
 -- Ideally the next one should be merged with the previous but keeping it separate is
@@ -404,41 +593,50 @@ states.selective = selective
 local function stacked(namespace,attribute,head,default) -- no triggering, no inheritance, but list-wise
     local stack, done = head, false
     local current, depth = default or 0, 0
+
+    local function check()
+        local a = has_attribute(stack,attribute)
+        if a then
+            if current ~= a then
+                head = insert_node_before(head,stack,copy_node(nsdata[a]))
+                depth = depth + 1
+                current, done = a, true
+            end
+        elseif default > 0 then
+            --
+        elseif current > 0 then
+            head = insert_node_before(head,stack,copy_node(nsnone))
+            depth = depth - 1
+            current, done = 0, true
+        end
+        return a
+    end
+
     while stack do
         local id = stack.id
-        if id == glyph_code or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
-            local c = has_attribute(stack,attribute)
-            if c then
-                if current ~= c then
-                    head = insert_node_before(head,stack,copy_node(nsdata[c]))
-                    depth = depth + 1
-                    current, done = c, true
-                end
-                if id == glue_code then
-                    local content = stack.leader
-                    if content then -- unchecked
-                        local ok = false
-                        stack.leader, ok = stacked(namespace,attribute,content,current)
-                        done = done or ok
-                    end
-                end
-            elseif default > 0 then
-                --
-            elseif current > 0 then
-                head = insert_node_before(head,stack,copy_node(nsnone))
-                depth = depth - 1
-                current, done = 0, true
+        if id == glyph_code then
+            check()
+        elseif id == rule_code then
+            if stack.width ~= 0 then
+                check()
+            end
+        elseif id == glue_code then
+            local content = stack.leader
+            if content and check() then
+                local ok = false
+                stack.leader, ok = stacked(namespace,attribute,content,current)
+                done = done or ok
             end
         elseif id == hlist_code or id == vlist_code then
             local content = stack.list
             if content then
              -- the problem is that broken lines gets the attribute which can be a later one
                 if nslistwise then
-                    local c = has_attribute(stack,attribute)
-                    if c and current ~= c and nslistwise[c] then -- viewerlayer
+                    local a = has_attribute(stack,attribute)
+                    if a and current ~= a and nslistwise[a] then -- viewerlayer / needs checking, see below
                         local p = current
-                        current, done = c, true
-                        head = insert_node_before(head,stack,copy_node(nsdata[c]))
+                        current, done = a, true
+                        head = insert_node_before(head,stack,copy_node(nsdata[a]))
                         stack.list = stacked(namespace,attribute,content,current)
                         head, stack = insert_node_after(head,stack,copy_node(nsnone))
                         current = p
@@ -471,24 +669,33 @@ local function stacker(namespace,attribute,head,default) -- no triggering, no in
     nsbegin()
     local current, previous, done, okay = head, head, false, false
     local attrib = default or unsetvalue
+
+    local function check()
+        local a = has_attribute(current,attribute) or unsetvalue
+        if a ~= attrib then
+            local n = nsstep(a)
+            if n then
+                head = insert_node_before(head,current,n) -- copy_node(nsdata[a]))
+            end
+            attrib, done, okay = a, true, true
+        end
+        return a
+    end
+
     while current do
         local id = current.id
-        if id == glyph_code or (id == rule_code and current.width ~= 0) or (id == glue_code and current.leader) then -- or disc_code
-            local a = has_attribute(current,attribute) or unsetvalue
-            if a ~= attrib then
-                local n = nsstep(a)
-                if n then
-                    head = insert_node_before(head,current,n) -- copy_node(nsdata[a]))
-                end
-                attrib, done, okay = a, true, true
+        if id == glyph_code then
+            check()
+        elseif id == rule_code then
+            if current.width ~= 0 then
+                check()
             end
-            if id == glue_code then
-                local content = current.leader
-                if content then -- unchecked
-                    local ok = false
-                    current.leader, ok = stacker(namespace,attribute,content,attrib)
-                    done = done or ok
-                end
+        elseif id == glue_code then
+            local content = current.leader
+            if content and check() then
+                local ok = false
+                current.leader, ok = stacker(namespace,attribute,content,attrib)
+                done = done or ok
             end
         elseif id == hlist_code or id == vlist_code then
             local content = current.list
@@ -497,9 +704,9 @@ local function stacker(namespace,attribute,head,default) -- no triggering, no in
                     local a = has_attribute(current,attribute)
                     if a and attrib ~= a and nslistwise[a] then -- viewerlayer
                         local p = attrib
-                        attrib, done = a, true
-                        head = insert_node_before(head,current,copy_node(nsdata[a]))
-                        current.list = stacker(namespace,attribute,content,attrib)
+                            attrib, done = a, true
+                            head = insert_node_before(head,current,copy_node(nsdata[a]))
+                            current.list = stacker(namespace,attribute,content,attrib)
                         head, current = insert_node_after(head,current,copy_node(nsnone))
                         attrib = p
                     else
diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua
index 0ed17a1b5..e654d9e0f 100644
--- a/tex/context/base/node-ini.lua
+++ b/tex/context/base/node-ini.lua
@@ -73,25 +73,29 @@ nodes.handlers = nodes.handlers or { }
 -- there will be more of this:
 
 local skipcodes = allocate {
-    [ 0] = "userskip",
-    [ 1] = "lineskip",
-    [ 2] = "baselineskip",
-    [ 3] = "parskip",
-    [ 4] = "abovedisplayskip",
-    [ 5] = "belowdisplayskip",
-    [ 6] = "abovedisplayshortskip",
-    [ 7] = "belowdisplayshortskip",
-    [ 8] = "leftskip",
-    [ 9] = "rightskip",
-    [10] = "topskip",
-    [11] = "splittopskip",
-    [12] = "tabskip",
-    [13] = "spaceskip",
-    [14] = "xspaceskip",
-    [15] = "parfillskip",
-    [16] = "thinmuskip",
-    [17] = "medmuskip",
-    [18] = "thickmuskip",
+    [  0] = "userskip",
+    [  1] = "lineskip",
+    [  2] = "baselineskip",
+    [  3] = "parskip",
+    [  4] = "abovedisplayskip",
+    [  5] = "belowdisplayskip",
+    [  6] = "abovedisplayshortskip",
+    [  7] = "belowdisplayshortskip",
+    [  8] = "leftskip",
+    [  9] = "rightskip",
+    [ 10] = "topskip",
+    [ 11] = "splittopskip",
+    [ 12] = "tabskip",
+    [ 13] = "spaceskip",
+    [ 14] = "xspaceskip",
+    [ 15] = "parfillskip",
+    [ 16] = "thinmuskip",
+    [ 17] = "medmuskip",
+    [ 18] = "thickmuskip",
+    [100] = "leaders",
+    [101] = "cleaders",
+    [102] = "xleaders",
+    [103] = "gleaders",
 }
 
 local penaltycodes = allocate { -- unfortunately not used
diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua
index 4522bef98..f68e89954 100644
--- a/tex/context/base/node-res.lua
+++ b/tex/context/base/node-res.lua
@@ -98,6 +98,8 @@ local leftskip          = register_node(new_node("glue",skipcodes.leftskip))
 local rightskip         = register_node(new_node("glue",skipcodes.rightskip))
 local temp              = register_node(new_node("temp",0))
 local noad              = register_node(new_node("noad"))
+local hlist             = register_node(new_node("hlist"))
+local vlist             = register_node(new_node("vlist"))
 
 function pool.zeroglue(n)
     local s = n.spec
@@ -284,6 +286,14 @@ function pool.noad()
     return copy_node(noad)
 end
 
+function pool.hlist()
+    return copy_node(hlist)
+end
+
+function pool.vlist()
+    return copy_node(vlist)
+end
+
 --[[
 <p>At some point we ran into a problem that the glue specification
 of the zeropoint dimension was overwritten when adapting a glue spec
diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv
index 1f1ac20ec..5b260e669 100644
--- a/tex/context/base/node-rul.mkiv
+++ b/tex/context/base/node-rul.mkiv
@@ -286,9 +286,6 @@
    \c!style=,
    \c!color=]
 
-\def\v!shiftup  {shiftup}
-\def\v!shiftdown{shiftdown}
-
 \defineshift [\v!shiftup]   [\c!method=0,\c!dy=-1,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
 \defineshift [\v!shiftdown] [\c!method=1,\c!dy=.3,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
 
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua
index 70e4639b8..64b8e84fb 100644
--- a/tex/context/base/node-tra.lua
+++ b/tex/context/base/node-tra.lua
@@ -726,6 +726,62 @@ function colors.set(n,c,s)
     end
 end
 
+function colors.setlist(n,c,s)
+    while n do
+        local mc = mapping[c]
+        if not mc then
+            unset_attribute(n,attribute)
+        else
+            if not get_attribute(n,colormodel) then
+                set_attribute(n,colormodel,s or 1)
+            end
+            set_attribute(n,attribute,mc)
+        end
+        n = n.next
+    end
+end
+
 function colors.reset(n)
     unset_attribute(n,attribute)
 end
+
+-- maybe
+
+local transparencies = { }
+tracers.transparencies = transparencies
+
+local attribute = attributes.private('transparency')
+local mapping   = attributes.list[attribute] or { }
+
+function transparencies.set(n,t)
+    local mt = mapping[t]
+    if not mt then
+        unset_attribute(n,attribute)
+    else
+        set_attribute(n,attribute,mt)
+    end
+end
+
+function transparencies.setlist(n,c,s)
+    while n do
+        local mt = mapping[c]
+        if not mt then
+            unset_attribute(n,attribute)
+        else
+            set_attribute(n,attribute,mt)
+        end
+        n = n.next
+    end
+end
+
+function transparencies.reset(n)
+    unset_attribute(n,attribute)
+end
+
+-- for the moment here
+
+nodes.visualizers = { }
+
+function nodes.visualizers.handler(head)
+    return head, false
+end
diff --git a/tex/context/base/node-typ.lua b/tex/context/base/node-typ.lua
index 5f8df2b44..6540ed478 100644
--- a/tex/context/base/node-typ.lua
+++ b/tex/context/base/node-typ.lua
@@ -13,6 +13,7 @@ local fontparameters = fonts.hashes.parameters
 
 local hpack          = node.hpack
 local vpack          = node.vpack
+local fast_hpack     = nodes.fasthpack
 
 local nodepool       = nodes.pool
 
@@ -62,6 +63,10 @@ function typesetters.hpack(str,fontid,spacing)
     return hpack(tonodes(str,fontid,spacing),"exactly")
 end
 
+function typesetters.fast_hpack(str,fontid,spacing)
+    return fast_hpack(tonodes(str,fontid,spacing),"exactly")
+end
+
 function typesetters.vpack(str,fontid,spacing)
     -- vpack is just a hack, and a proper implentation is on the agenda
     -- as it needs more info etc than currently available
diff --git a/tex/context/base/pack-mrl.mkiv b/tex/context/base/pack-mrl.mkiv
index f3f3d11d9..dae6acf47 100644
--- a/tex/context/base/pack-mrl.mkiv
+++ b/tex/context/base/pack-mrl.mkiv
@@ -185,42 +185,42 @@
 %D
 %D \showsetup{setupmarginrules}
 
-\unexpanded\def\setupmarginrules
-  {\dodoubleargument\getparameters[\??ka]}
-
-%D \macros
-%D   {startmarginrule}
-%D
-%D The second method collects text and reformats it afterwards,
-%D using the shapebox macros. We prevent local margin rules.
-%D
-%D \showsetup{startmarginrule}
-
-\definecomplexorsimple\startmarginrule
-
-\def\simplestartmarginrule
-  {\bgroup
-   \let\drawmarginrule\relax
-   \let\stopmarginrule\dostopmarginrule
-   \beginofshapebox}
-
-\def\complexstartmarginrule[#1]%
-  {\bgroup
-   \let\drawmarginrule\relax
-   \ifnum#1<\@@kalevel\relax
-     \let\stopmarginrule\egroup
-   \else
-     \def\@@kadefaultwidth{#1}%
-     \let\stopmarginrule\dostopmarginrule
-     \expandafter\beginofshapebox
-   \fi}
-
-\def\dostopmarginrule
-  {\endofshapebox
-   \reshapebox
-     {\hbox{\inleftmargin{\dodrawmarginrule}\box\shapebox}}%
-   \flushshapebox
-   \egroup}
+% \unexpanded\def\setupmarginrules
+%   {\dodoubleargument\getparameters[\??ka]}
+%
+% %D \macros
+% %D   {startmarginrule}
+% %D
+% %D The second method collects text and reformats it afterwards,
+% %D using the shapebox macros. We prevent local margin rules.
+% %D
+% %D \showsetup{startmarginrule}
+%
+% \definecomplexorsimple\startmarginrule
+%
+% \def\simplestartmarginrule
+%   {\bgroup
+%    \let\drawmarginrule\relax
+%    \let\stopmarginrule\dostopmarginrule
+%    \beginofshapebox}
+%
+% \def\complexstartmarginrule[#1]%
+%   {\bgroup
+%    \let\drawmarginrule\relax
+%    \ifnum#1<\@@kalevel\relax
+%      \let\stopmarginrule\egroup
+%    \else
+%      \def\@@kadefaultwidth{#1}%
+%      \let\stopmarginrule\dostopmarginrule
+%      \expandafter\beginofshapebox
+%    \fi}
+%
+% \def\dostopmarginrule
+%   {\endofshapebox
+%    \reshapebox
+%      {\hbox{\inleftmargin{\dodrawmarginrule}\box\shapebox}}%
+%    \flushshapebox
+%    \egroup}
 
 %D \startbuffer
 %D \setupmarginrules[level=5]
@@ -818,9 +818,9 @@
 
 %D Will move up:
 
-\setupmarginrules
-  [\c!level=0,
-   \c!rulethickness=\@@kadefaultwidth\linewidth]
+% \setupmarginrules
+%   [\c!level=0,
+%    \c!rulethickness=\@@kadefaultwidth\linewidth]
 
 \setupthinrules
   [\c!interlinespace=\v!small,
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index aad08ef3e..78d7f892e 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -215,7 +215,6 @@
   {\vbox\bgroup % intercept spurious spaces
      \the\everybeforepagebody
      \starttextproperties
-     \dontshowboxes
      \checkmarginblocks
      \the\beforeeverypage
      \normalexpanded{\global\beforepage\emptytoks\the\beforepage}%
diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv
index eeb5cadfd..47665e8b5 100644
--- a/tex/context/base/spac-hor.mkiv
+++ b/tex/context/base/spac-hor.mkiv
@@ -466,8 +466,15 @@
 
 % Bovendien definieren we enkele extra \fill's:
 
-\unexpanded\def\hfilll{\hskip\zeropoint\!!plus1filll\relax}
-\unexpanded\def\vfilll{\vskip\zeropoint\!!plus1filll\relax}
+\unexpanded\def\hfilll   {\hskip\zeropoint\!!plus1filll\relax}
+\unexpanded\def\vfilll   {\vskip\zeropoint\!!plus1filll\relax}
+
+%unexpanded\def\hfilneg  {\hskip\zeropoint\!!plus-1fil\relax}
+\unexpanded\def\hfillneg {\hskip\zeropoint\!!plus-1fill\relax}
+\unexpanded\def\hfilllneg{\hskip\zeropoint\!!plus-1filll\relax}
+%unexpanded\def\vfilneg  {\vskip\zeropoint\!!plus-1fil\relax}
+\unexpanded\def\vfillneg {\vskip\zeropoint\!!plus-1fill\relax}
+\unexpanded\def\vfilllneg{\vskip\zeropoint\!!plus-1filll\relax}
 
 \unexpanded\def\tfskip    {\begingroup\tf\hskip\emwidth\endgroup}
 \unexpanded\def\dotfskip#1{\begingroup\tf\hskip      #1\endgroup} % used elsewhere
@@ -576,9 +583,6 @@
 
 \let\stopnarrow\spac_narrower_stop
 
-% \def\v!narrower{narrower}
-% \definenarrower[\v!narrower]
-
 \newdimen\d_spac_effective_hsize     \def\effectivehsize    {\hsize}
 \newdimen\d_spac_effective_leftskip  \def\effectiveleftskip {\leftskip}
 \newdimen\d_spac_effective_rightskip \def\effectiverightskip{\rightskip}
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index c6d8ea788..09ab902cd 100644
Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index fd6b58ce4..860ca0e03 100644
Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index 14727c77b..aa5aa4d20 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -150,17 +150,17 @@ return {
             status   = "okay",
         },
         {
-            filename = "mult-def",
+            filename = "mult-aux",
             marktype = "mkiv",
             status   = "okay",
         },
         {
-            filename = "mult-chk",
+            filename = "mult-def",
             marktype = "mkiv",
             status   = "okay",
         },
         {
-            filename = "mult-aux",
+            filename = "mult-chk",
             marktype = "mkiv",
             status   = "okay",
         },
@@ -277,12 +277,12 @@ return {
             marktype = "mkiv",
             status   = "okay",
         },
-        {
-            filename = "supp-vis",
-            marktype = "mkiv",
-            status   = "unknown",
-            comment  = "will become a module (and part will stay in the core)",
-        },
+     -- {
+     --     filename = "supp-vis",
+     --     marktype = "mkiv",
+     --     status   = "unknown",
+     --     comment  = "will become a module (and part will stay in the core)",
+     -- },
         {
             filename = "supp-fun",
             marktype = "mkiv",
@@ -625,12 +625,6 @@ return {
             status   = "okay",
             comment  = "in transition",
         },
-        {
-            filename = "anch-pgr",
-            marktype = "mkiv",
-            status   = "okay",
-            comment  = "in transition",
-        },
         {
             filename = "scrn-ini",
             marktype = "mkvi",
@@ -852,27 +846,27 @@ return {
         {
             filename = "buff-imp-tex",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "buff-imp-mp",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "buff-imp-lua",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "buff-imp-xml",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "buff-imp-parsed-xml",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "strc-blk",
@@ -1077,7 +1071,7 @@ return {
         },
         {
             filename = "font-gds",
-            marktype = "mkiv",
+            marktype = "mkvi",
             status   = "okay",
         },
         {
@@ -1102,6 +1096,11 @@ return {
             status   = "okay",
             comment  = "work in progress",
         },
+        {
+            filename = "trac-vis",
+            marktype = "mkvi",
+            status   = "okay",
+        },
         {
             filename = "typo-cln",
             marktype = "mkiv",
@@ -1238,12 +1237,14 @@ return {
         {
             filename = "anch-pgr",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
+            comment  = "in transition",
         },
         {
             filename = "anch-bck",
             marktype = "mkvi",
-            status   = "unknown",
+            status   = "okay",
+            comment  = "in transition",
         },
         {
             filename = "anch-tab",
@@ -1253,12 +1254,13 @@ return {
         {
             filename = "anch-bar",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "anch-snc",
             marktype = "mkiv",
             status   = "unknown",
+            comment  = "interesting old mechanism to keep around (module?)",
         },
         {
             filename = "math-ini",
@@ -1402,12 +1404,12 @@ return {
         {
             filename = "grph-inc",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "grph-fig",
             marktype = "mkiv",
-            status   = "unknown",
+            status   = "okay",
         },
         {
             filename = "grph-raw",
diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex
index 34bb8ec53..266e26966 100644
--- a/tex/context/base/status-mkiv.tex
+++ b/tex/context/base/status-mkiv.tex
@@ -179,7 +179,7 @@
  --
  -- context.stoptitle()
 
-    context.starttitle { title = "Messy namespaces" }
+    context.starttitle { title = "messy namespaces" }
 
     local namespaces = dofile("status-namespaces.lua")
 
@@ -193,7 +193,7 @@
 
     context.stoptitle()
 
-    context.starttitle { title = "Messy registers" }
+    context.starttitle { title = "messy registers" }
 
     local registers  = dofile("status-registers.lua")
 
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi
index 956acaae5..a795b429c 100644
--- a/tex/context/base/strc-con.mkvi
+++ b/tex/context/base/strc-con.mkvi
@@ -36,8 +36,6 @@
 
 \unprotect
 
-\ifdefined\v!construction \else \def\v!construction{construction} \fi
-
 %D Todo:
 
 \installcorenamespace{construction}
diff --git a/tex/context/base/strc-doc.mkiv b/tex/context/base/strc-doc.mkiv
index 14c6537db..0263095eb 100644
--- a/tex/context/base/strc-doc.mkiv
+++ b/tex/context/base/strc-doc.mkiv
@@ -17,8 +17,6 @@
 
 \unprotect
 
-\def\c!xmlsetup{xmlsetup}
-
 % We operate in a \type {@@ns} namespace. All data is passed through
 % variables. Of course we can built another interface on top of this
 % that accepts multiple arguments. We might change this approach and
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 05cfa40e3..000b74831 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -1793,7 +1793,6 @@
    \forgetall
    \postponenotes
    \dontcomplain
-   %\showcomposition
    \setbox\b_strc_floats_content\vbox{\borderedfloatbox}%
   %\page_backgrounds_add_local_to_box\b_strc_floats_content
    \ifnofloatcaption
diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi
index 16544f866..049051731 100644
--- a/tex/context/base/strc-lst.mkvi
+++ b/tex/context/base/strc-lst.mkvi
@@ -28,12 +28,6 @@
 
 \unprotect
 
-% To be added to mult-def.lua:
-
-\ifdefined\c!renderingsetup \else \def\c!renderingsetup{renderingsetup} \fi % maybe not interfaced
-\ifdefined\c!filler         \else \def\c!filler        {filler}         \fi
-\ifdefined\v!interactive    \else \def\v!interactive   {interactive}    \fi
-
 %D Lists are mostly used for tables of contents but are in fact a rather generic
 %D feature of \CONTEXT. We seperate between storage and rendering and the current
 %D implementation is a reworked version of all that was added in steps. As lists
diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi
index ce37a5717..5ee432761 100644
--- a/tex/context/base/strc-not.mkvi
+++ b/tex/context/base/strc-not.mkvi
@@ -21,10 +21,6 @@
 
 % todo: see if we can now use \insertpenalties (>0 == some left)
 
-\ifdefined\v!notation      \else \def\v!notation     {notation}      \fi
-\ifdefined\v!endnote       \else \def\v!endnote      {endnote}       \fi
-\ifdefined\c!symbolcommand \else \def\c!symbolcommand{symbolcommand} \fi
-
 \ifdefined\dotagsetnotesymbol \else \let\dotagsetnotesymbol\relax \fi
 
 \unexpanded\def\unvboxed {\ifvmode\unvbox \else\box \fi} % will change or used more often
diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv
index 4ebac304d..a4afecf52 100644
--- a/tex/context/base/syst-ini.mkiv
+++ b/tex/context/base/syst-ini.mkiv
@@ -443,6 +443,17 @@
 
 \let\leavevmode\unvoidbox % we prefer to use \dontleavehmode
 
+%D \macros
+%D   {dontcomplain}
+%D
+%D We need this one soon:
+
+\normalprotected\def\dontcomplain
+  {\hbadness\plustenthousand
+   \vbadness\plustenthousand
+   \hfuzz   \maxdimen
+   \vfuzz   \maxdimen}
+
 %D Some expected plain variants follow. We don't reuse registers
 %D because we don't want clashes.
 
diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua
index 1ec38e181..ffcb82cd9 100644
--- a/tex/context/base/task-ini.lua
+++ b/tex/context/base/task-ini.lua
@@ -61,6 +61,8 @@ appendaction("shipouts",     "normalizers", "nodes.handlers.backgrounds")
 
 --~ appendaction("shipouts",     "normalizers", "nodes.handlers.export")                             -- disabled
 
+appendaction("shipouts",     "finishers",   "nodes.visualizers.handler")                         -- disabled
+
 appendaction("shipouts",     "finishers",   "attributes.colors.handler")                         -- disabled
 appendaction("shipouts",     "finishers",   "attributes.transparencies.handler")                 -- disabled
 appendaction("shipouts",     "finishers",   "attributes.colorintents.handler")                   -- disabled
@@ -122,6 +124,7 @@ disableaction("shipouts",    "attributes.effects.handler")
 disableaction("shipouts",    "attributes.negatives.handler")
 disableaction("shipouts",    "attributes.viewerlayers.handler")
 disableaction("shipouts",    "structures.tags.handler")
+disableaction("shipouts",    "nodes.visualizers.handler")
 disableaction("shipouts",    "nodes.handlers.accessibility")
 disableaction("shipouts",    "nodes.handlers.backgrounds")
 disableaction("shipouts",    "nodes.handlers.cleanuppage")
diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua
new file mode 100644
index 000000000..e2f52730b
--- /dev/null
+++ b/tex/context/base/trac-vis.lua
@@ -0,0 +1,585 @@
+if not modules then modules = { } end modules ['trac-vis'] = {
+    version   = 1.001,
+    comment   = "companion to trac-vis.mkiv",
+    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+    copyright = "PRAGMA ADE / ConTeXt Development Team",
+    license   = "see context related readme files"
+}
+
+local string, number, table = string, number, table
+local node, nodes, attributes, fonts, tex = node, nodes, attributes, fonts, tex
+
+local format = string.format
+
+-- This module started out in the early days of mkiv and luatex with
+-- visualizing kerns related to fonts. In the process of cleaning up the
+-- visual debugger code it made sense to integrate some other code that
+-- I had laying around and replace the old supp-vis debugging code. As
+-- only a subset of the old visual debugger makes sense it has become a
+-- different implementation. Soms of the m-visual functionality will also
+-- be ported. The code is rather trivial. The caching is not really needed
+-- but saves upto 50% of the time needed to add visualization. Of course
+-- the overall runtime is larger because of color and layer processing in
+-- the backend (can be times as much) so the runtime is somewhat larger
+-- with full visualization enabled. In practice this will never happen
+-- unless one is demoing.
+
+-- todo: global switch (so no attributes)
+-- todo: maybe also xoffset, yoffset of glyph
+
+local nodecodes           = nodes.nodecodes
+local disc_code           = nodecodes.disc
+local kern_code           = nodecodes.kern
+local glyph_code          = nodecodes.glyph
+local hlist_code          = nodecodes.hlist
+local vlist_code          = nodecodes.vlist
+local glue_code           = nodecodes.glue
+local penalty_code        = nodecodes.penalty
+
+local kerncodes           = nodes.kerncodes
+local font_kern_code      = kerncodes.fontkern
+local user_kern_code      = kerncodes.userkern
+
+local gluecodes           = nodes.gluecodes
+local cleaders_code       = gluecodes.cleaders
+local space_code          = gluecodes.space
+local xspace_code         = gluecodes.xspace
+local leftskip_code       = gluecodes.leftskip
+local rightskip_code      = gluecodes.rightskip
+
+local concat_nodes        = nodes.concat
+local hpack_nodes         = node.hpack
+local vpack_nodes         = node.vpack
+local hpack_string        = typesetters.hpack
+local fast_hpack_string   = typesetters.fast_hpack
+local copy_node           = node.copy
+local copy_list           = node.copy_list
+local free_node           = node.free
+local free_node_list      = node.flush_list
+local has_attribute       = node.has_attribute
+local set_attribute       = node.set_attribute
+local insert_before       = node.insert_before
+local fast_hpack          = nodes.fasthpack
+
+local tex_attribute       = tex.attribute
+local unsetvalue          = attributes.unsetvalue
+
+local current_font        = font.current
+
+local exheights           = fonts.hashes.exheights
+local emwidths            = fonts.hashes.emwidths
+local pt_factor           = number.dimenfactors.pt
+
+local nodepool            = nodes.pool
+local new_rule            = nodepool.rule
+local new_kern            = nodepool.kern
+local new_glue            = nodepool.glue
+local new_penalty         = nodepool.penalty
+
+local tracers             = nodes.tracers
+local visualizers         = nodes.visualizers
+
+local setcolor            = tracers.colors.set
+local setlistcolor        = tracers.colors.setlist
+local settransparency     = tracers.transparencies.set
+local setlisttransparency = tracers.transparencies.setlist
+
+local starttiming         = statistics.starttiming
+local stoptiming          = statistics.stoptiming
+
+-- local function setlistattribute(list,a,v)
+--     while list do
+--         set_attribute(list,a,v)
+--         list = list.next
+--     end
+-- end
+
+local a_visual            = attributes.private("visual")
+local a_fontkern          = attributes.private("fontkern")
+local a_layer             = attributes.private("viewerlayer")
+
+local hasbit              = number.hasbit
+local bit                 = number.bit
+local setbit              = number.setbit
+local clearbit            = number.clearbit
+
+local trace_hbox     --  1
+local trace_vbox     --  2
+local trace_kern     --  4
+local trace_glue     --  8
+local trace_penalty  -- 16
+local trace_fontkern -- 32
+
+local report_visualize = logs.reporter("visualize")
+
+local modes = {
+    hbox     =  1,
+    vbox     =  2,
+    kern     =  4,
+    glue     =  8,
+    penalty  = 16,
+    fontkern = 32,
+}
+
+local usedfont, exheight, emwidth
+local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox
+
+local enabled = false
+
+function visualizers.setfont(id)
+    usedfont = id or current_font()
+    exheight = exheights[usedfont]
+    emwidth = emwidths[usedfont]
+end
+
+local function setvisual(n,a,what) -- this will become more efficient when we have the bit lib linked in
+    if not n or n == "reset" then
+        return unsetvalue
+    elseif n == "makeup" then
+        a = setvisual("hbox",a)
+        a = setvisual("vbox",a)
+        a = setvisual("kern",a)
+        a = setvisual("glue",a)
+        a = setvisual("penalty",a)
+    elseif n == "all" then
+        if what == false then
+            return unsetvalue
+        else
+            for k, v in next, modes do
+                a = setvisual(k,a)
+            end
+        end
+    else
+        local m = modes[n]
+        if m then
+            if a == unsetvalue then
+                if what == false then
+                    return unsetvalue
+                else
+                    a = setbit(0,m)
+                end
+            elseif what == false then
+                a = clearbit(a,m)
+            else
+                a = setbit(a,m)
+            end
+        elseif not a then
+            return unsetvalue
+        end
+    end
+    if a == unsetvalue or a == 0 then
+        return unsetvalue
+    elseif not enabled then -- must happen at runtime (as we don't store layers yet)
+        if not usedfont then
+            -- we use a narrow monospaced font
+            visualizers.setfont(fonts.definers.define { name = "lmmonoltcond10regular", size = tex.sp("4pt") })
+        end
+        local layers = { }
+        for mode, value in next, modes do
+            local tag = format("v_%s",mode)
+            attributes.viewerlayers.define {
+                tag       = format(tag),
+                title     = format("visualizer %s",mode),
+                visible   = "start",
+                editable  = "yes",
+                printable = "yes"
+            }
+            layers[mode] = attributes.viewerlayers.register(tag,true)
+        end
+        l_penalty  = layers.penalty
+        l_glue     = layers.glue
+        l_kern     = layers.kern
+        l_fontkern = layers.fontkern
+        l_hbox     = layers.hbox
+        l_vbox     = layers.vbox
+        nodes.tasks.enableaction("shipouts","nodes.visualizers.handler")
+        report_visualize("enabled")
+        enabled = true
+    end
+    return a
+end
+
+function visualizers.setvisual(n)
+    tex_attribute[a_visual] = setvisual(n,tex_attribute[a_visual])
+end
+
+commands.setvisual = visualizers.setvisual
+
+function commands.visual(n)
+    context(setvisual(n,0))
+end
+
+local function set(mode,v)
+    tex_attribute[a_visual] = setvisual(mode,tex_attribute[a_visual],v)
+end
+
+for mode, value in next, modes do
+    trackers.register(format("visualizers.%s",mode), function(v) set(mode,v) end)
+end
+
+trackers.register("visualizers.all",   function(v) set("all",   v) end)
+trackers.register("visualizers.makeup",function(v) set("makeup",v) end)
+trackers.register("visualizers.reset", function(v) set("reset", v) end)
+
+local c_positive   = "trace:b"
+local c_negative   = "trace:r"
+local c_zero       = "trace:g"
+local c_text       = "trace:s"
+local c_space      = "trace:y"
+local c_skip       = "trace:c"
+
+local c_positive_d = "trace:db"
+local c_negative_d = "trace:dr"
+local c_zero_d     = "trace:dg"
+local c_text_d     = "trace:ds"
+local c_space_d    = "trace:dy"
+local c_skip_d     = "trace:dc"
+
+-- inlining the concat could speed it up
+
+local function sometext(color,layer,fmt,...)
+    local text = fast_hpack_string(format(fmt,...),usedfont)
+    local size = text.width
+    local rule = new_rule(size,2*exheight,exheight/2)
+    local kern = new_kern(-size)
+    setcolor(rule,color)
+    local info = concat_nodes {
+        rule,
+        kern,
+        text,
+    }
+    setlisttransparency(info,c_zero)
+    info = fast_hpack(info)
+    set_attribute(info,a_layer,layer)
+    info.width = 0
+    info.height = 0
+    info.depth = 0
+    return info
+end
+
+local f_cache = { }
+
+local function fontkern(head,current)
+    local kern = current.kern
+    local info = f_cache[kern]
+    if info then
+        -- print("hit fontkern")
+    else
+        local text = fast_hpack_string(format(" %0.3f",kern*pt_factor),usedfont)
+        local rule = new_rule(emwidth/10,6*exheight,2*exheight)
+        local list = text.list
+        if kern > 0 then
+            setlistcolor(list,c_positive_d)
+        elseif kern < 0 then
+            setlistcolor(list,c_negative_d)
+        else
+            setlistcolor(list,c_zero_d)
+        end
+        setlisttransparency(list,c_text_d)
+        settransparency(rule,c_text_d)
+        text.shift = -5 * exheight
+        info = concat_nodes {
+            rule,
+            text,
+        }
+        info = fast_hpack(info)
+        set_attribute(info,a_layer,l_fontkern)
+        info.width = 0
+        info.height = 0
+        info.depth = 0
+        f_cache[kern] = info
+    end
+    head, current = insert_before(head,current,copy_list(info))
+    return head, current.next
+end
+
+-- cache baseline
+
+local b_cache
+
+local function ruledbox(head, current, vertical)
+    local wd = current.width
+    if wd ~= 0 then
+        local ht, dp = current.height, current.depth
+        local next, prev = current.next, current.prev
+        current.next, current.prev = nil, nil
+        local linewidth = .1 * emwidth
+        local baseline
+        if dp ~= 0 and ht ~= 0 then
+            if not b_cache then
+                -- due to an optimized leader color/transparency we need to se the glue node in order
+                -- to trigger this mechanism
+                b_cache = new_glue(0)
+                local leader = concat_nodes {
+                    new_glue(2.5*linewidth),
+                    new_rule(5*linewidth,linewidth,0),
+                    new_glue(2.5*linewidth),
+                }
+             -- setlisttransparency(leader,c_text)
+                leader = fast_hpack(leader)
+             -- setlisttransparency(leader,c_text)
+                b_cache.leader = leader
+                b_cache.subtype = cleaders_code
+                b_cache.spec.stretch = 65536
+                b_cache.spec.stretch_order = 2
+                setlisttransparency(b_cache,c_text)
+            end
+            baseline = copy_list(b_cache)
+            baseline = fast_hpack(baseline,wd-2*linewidth)
+            -- or new hpack node, set head and also:
+            -- baseline.width = wd
+            -- baseline.glue_set = wd/65536
+            -- baseline.glue_order = 2
+            -- baseline.glue_sign = 1
+        end
+        local info = concat_nodes {
+            new_rule(linewidth,ht,dp),
+            new_rule(wd-2*linewidth,-dp+linewidth,dp),
+            new_rule(linewidth,ht,dp),
+            new_kern(-wd+linewidth),
+            new_rule(wd-2*linewidth,ht,-ht+linewidth),
+            new_kern(-wd+linewidth),
+            baseline,
+        }
+        setlisttransparency(info,c_text)
+        info = fast_hpack(info)
+        info.width = 0
+        info.height = 0
+        info.depth = 0
+        set_attribute(info,a_layer,vertical and l_vbox or l_hbox)
+        local info = concat_nodes {
+            info,
+            current,
+        }
+        info = fast_hpack(info)
+        if vertical then
+            info = vpack_nodes(info)
+        end
+        if next then
+            info.next = next
+            next.prev = info
+        end
+        if prev then
+            info.prev = prev
+            prev.next = info
+        end
+        if head == current then
+            return info, info
+        else
+            return head, info
+        end
+    else
+        return head, current
+    end
+end
+
+local g_cache = { }
+
+local function ruledglue(head,current,vertical)
+    local spec = current.spec
+    local width = spec.width
+    local subtype = current.subtype
+    local info = g_cache[width]
+    if info then
+        -- print("glue hit")
+    else
+        if subtype == space_code or subtype == xspace_code then -- not yet all space
+            info = sometext(c_space   ,l_glue,"SP:%0.3f",                         width*pt_factor)
+        elseif subtype == leftskip_code then
+            info = sometext(c_skip    ,l_glue,"LS:%0.3f",                         width*pt_factor)
+        elseif subtype == rightskip_code then
+            info = sometext(c_skip    ,l_glue,"RS:%0.3f",                         width*pt_factor)
+        elseif width > 0 then
+            info = sometext(c_positive,l_glue,"%sS:%0.3f",vertical and "V" or "H",width*pt_factor)
+        elseif width < 0 then
+            info = sometext(c_negative,l_glue,"%sS:%0.3f",vertical and "V" or "H",width*pt_factor)
+        else
+            info = sometext(c_zero    ,l_glue,"%sS:%0.3f",vertical and "V" or "H",width*pt_factor)
+        end
+        g_cache[width] = info
+    end
+    info = copy_list(info)
+    if vertical then
+        info = vpack_nodes(info)
+    end
+    head, current = insert_before(head,current,info)
+    return head, current.next
+end
+
+local k_cache = { }
+
+local function ruledkern(head,current,vertical)
+    local kern = current.kern
+    local info = k_cache[kern]
+    if info then
+        -- print("kern hit")
+    else
+        if kern > 0 then
+            info = sometext(c_positive,l_kern,"%sK:%0.3f",vertical and "V" or "H",kern*pt_factor)
+        elseif kern < 0 then
+            info = sometext(c_negative,l_kern,"%sK:%0.3f",vertical and "V" or "H",kern*pt_factor)
+        else
+            info = sometext(c_zero    ,l_kern,"%sK:%0.3f",vertical and "V" or "H",kern*pt_factor)
+        end
+        k_cache[kern] = info
+    end
+    info = copy_list(info)
+    if vertical then
+        info = vpack_nodes(info)
+    end
+    head, current = insert_before(head,current,info)
+    return head, current.next
+end
+
+local p_cache = { }
+
+local function ruledpenalty(head,current,vertical)
+    local penalty = current.penalty
+    local info = p_cache[penalty]
+    if info then
+        -- print("penalty hit")
+    else
+        if penalty > 0 then
+            info = sometext(c_positive,l_penalty,"%sP:%s",vertical and "V" or "H",penalty)
+        elseif penalty < 0 then
+            info = sometext(c_negative,l_penalty,"%sP:%s",vertical and "V" or "H",penalty)
+        else
+            info = sometext(c_zero    ,l_penalty,"%sP:%s",vertical and "V" or "H",penalty)
+        end
+        p_cache[penalty] = info
+    end
+    info = copy_list(info)
+    if vertical then
+        info = vpack_nodes(info)
+    end
+    head, current = insert_before(head,current,info)
+    return head, current.next
+end
+
+local function visualize(head,vertical)
+    local trace_hbox     = false
+    local trace_vbox     = false
+    local trace_kern     = false
+    local trace_glue     = false
+    local trace_penalty  = false
+    local trace_fontkern = false
+    local current = head
+    local prev_trace_fontkern = nil
+    local attr = unsetvalue
+    while current do
+        local id = current.id
+        local a = has_attribute(current,a_visual)
+        if a ~= attr then
+            prev_trace_fontkern = trace_fontkern
+            if not a then
+                trace_hbox     = false
+                trace_vbox     = false
+                trace_kern     = false
+                trace_glue     = false
+                trace_penalty  = false
+                trace_fontkern = false
+            else
+                trace_hbox     = hasbit(a,1)
+                trace_vbox     = hasbit(a,2)
+                trace_kern     = hasbit(a,4)
+                trace_glue     = hasbit(a,8)
+                trace_penalty  = hasbit(a,16)
+                trace_fontkern = hasbit(a,32)
+            end
+            attr = a
+        end
+        if id == kern_code then
+            local subtype = current.subtype
+            -- tricky ... we don't copy the trace attribute in node-inj (yet)
+            if subtype == font_kern_code or has_attribute(current,a_fontkern) then
+                if trace_fontkern or prev_trace_fontkern then
+                    head, current = fontkern(head,current)
+                end
+            elseif subtype == user_kern_code then
+                if trace_kern then
+                    head, current = ruledkern(head,current,vertical)
+                end
+            end
+        elseif id == glue_code then
+            local content = current.leader
+            if content then
+                current.leaders = visualize(content,false)
+            elseif trace_glue then
+                head, current = ruledglue(head,current,vertical)
+            end
+        elseif id == penalty_code then
+            if trace_penalty then
+                head, current = ruledpenalty(head,current,vertical)
+            end
+        elseif id == disc_code then
+            current.pre = visualize(current.pre)
+            current.post = visualize(current.post)
+            current.replace = visualize(current.replace)
+        elseif id == hlist_code then
+            local content = current.list
+            if content then
+                current.list = visualize(content,false)
+            end
+            if trace_hbox then
+                head, current = ruledbox(head,current,false)
+            end
+        elseif id == vlist_code then
+            local content = current.list
+            if content then
+                current.list = visualize(content,true)
+            end
+            if trace_vbox then
+                head, current = ruledbox(head,current,true)
+            end
+        end
+        current = current.next
+    end
+    return head
+end
+
+local function freed(cache)
+    local n = 0
+    for k, v in next, cache do
+        free_node_list(v)
+        n = n + 1
+    end
+    if n == 0 then
+        return 0, cache
+    else
+        return n, { }
+    end
+end
+
+local function cleanup()
+    local hf, ng, np, nk
+    nf, f_cache = freed(f_cache)
+    ng, g_cache = freed(g_cache)
+    np, p_cache = freed(p_cache)
+    nk, k_cache = freed(k_cache)
+    if b_cache then
+        free_node_list(b_cache)
+        b_cache = nil
+    end
+ -- report_visualize("cache: %s fontkerns, %s skips, %s penalties, %s kerns",nf,ng,np,nk)
+end
+
+function visualizers.handler(head)
+    if usedfont then
+        starttiming(visualizers)
+        head = visualize(head)
+--      cleanup()
+        stoptiming(visualizers)
+    end
+    return head, false
+end
+
+function nodes.visualizers.box(n)
+    tex.box[n].list = nodes.visualizers.handler(tex.box[n].list)
+end
+
+statistics.register("visualization time",function()
+    if enabled then
+        cleanup() -- in case we don't don't do it each time
+        return format("%s seconds",statistics.elapsedtime(visualizers))
+    end
+end)
diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv
new file mode 100644
index 000000000..256c648fc
--- /dev/null
+++ b/tex/context/base/trac-vis.mkiv
@@ -0,0 +1,111 @@
+%D \module
+%D   [       file=trac-vis, % replaces supp-vis plus some s-* modules
+%D        version=2112.06.23, % 1996.10.21,
+%D          title=\CONTEXT\ Tracing Macros,
+%D       subtitle=Visualization,
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D The old visual debugger dates from 1996 and started out as joke. In practice
+%D it's not used that often although the \type {\ruledhbox} cum suis macros come
+%D in handy when writing code. In the process of luafication some additional
+%D tracing options were tested, for instance showing font kerns. As part of the
+%D \MKIV\ cleanup the decision was made to reimplement, reintegrate and reconsider
+%D all these features. The old code is gone and the new code will get extended
+%D when needed. We still provide placeholders for some old visualization commands
+%D but they might go away.
+%D
+%D Control over what gets visualized happens with the tracker command:
+%D
+%D \enabletrackers[...]
+%D
+%D Possible values are: \type {fontkern}, \type {kern}, \type {glue}, \type
+%D {penalty}, \type {hbox}, \type {vbox}, \type {all}, \type {reset}, \type
+%D {makeup}.
+%D
+%D In due time some special visualzation of math will move here as well.
+
+\writestatus{loading}{ConTeXt Tracing Macros / Visualization}
+
+\registerctxluafile{trac-vis}{1.001}
+
+\unprotect
+
+\definesystemattribute[visual][public,global]
+
+%D We only provide box visualizers as they can come in handy for testing
+%D macros. In due time we will move some of the m-visual code here too.
+
+
+\unexpanded\def\ruledhbox{\hbox attr \visualattribute \ctxcommand{visual("hbox")} }
+\unexpanded\def\ruledvbox{\vbox attr \visualattribute \ctxcommand{visual("vbox")} }
+\unexpanded\def\ruledvtop{\vtop attr \visualattribute \ctxcommand{visual("vbox")} }
+
+\unexpanded\def\showmakeup
+  {\ctxcommand{setvisual("makeup")} }
+
+\unexpanded\def\setvisualizerfont
+  {\dosingleempty\syst_visualizers_setfont}
+
+\def\syst_visualizers_setfont[#1]% somename at 4pt
+  {\begingroup
+   \doifelsenothing{#1}{\definedfont[Mono at 4pt]}{\definedfont[#1]}%
+   \ctxlua{nodes.visualizers.setfont()}%
+   \endgroup}
+
+%D We keep this one:
+
+\unexpanded\def\dontinterfere
+  {\everypar \emptytoks
+   \let\par  \endgraf
+   \parindent\zeropoint
+   \parskip  \zeropoint
+   \leftskip \zeropoint
+   \rightskip\zeropoint
+   \relax}
+
+%D We keep these for a while:
+
+\let\ruledvcenter   \vcenter
+\let\ruledhss       \hss
+\let\ruledhfil      \hfil
+\let\ruledhfill     \hfill
+\let\ruledhfilll    \hfilll
+\let\ruledhfilneg   \hfilneg
+\let\ruledhfillneg  \hfillneg
+\let\ruledhfilllneg \hfilllneg
+\let\ruledvss       \vss
+\let\ruledvfil      \vfil
+\let\ruledvfill     \vfill
+\let\ruledvfilll    \vfilll
+\let\ruledvfilneg   \vfilneg
+\let\ruledvfillneg  \vfillneg
+\let\ruledvfilllneg \vfilllneg
+\let\ruledhskip     \hskip
+\let\ruledvskip     \vskip
+\let\ruledkern      \kern
+\let\ruledhglue     \hglue
+\let\ruledvglue     \vglue
+\let\ruledmkern     \mkern
+\let\ruledmskip     \mskip
+\let\ruledpenalty   \penalty
+
+%D And for some time we will keep these as well:
+
+\let\showfils            \relax
+\let\dontshowfils        \relax
+\let\showboxes           \relax
+\let\dontshowboxes       \relax
+\let\showskips           \relax
+\let\dontshowskips       \relax
+\let\showpenalties       \relax
+\let\dontshowpenalties   \relax
+\let\showcomposition     \relax
+\let\dontshowcomposition \relax
+
+\protect \endinput
diff --git a/tex/context/base/typo-krn.mkiv b/tex/context/base/typo-krn.mkiv
index e1e404a7b..20ca3ca89 100644
--- a/tex/context/base/typo-krn.mkiv
+++ b/tex/context/base/typo-krn.mkiv
@@ -62,7 +62,7 @@
 %D then we always would get a command defined which is not beforehand
 %D a good idea.
 
-\def\v!kerncharacters{kerncharacters} % no time now for translations
+\def\v!kerncharacters{kerncharacters} % no time now for translations should be a e! actually
 
 \definecharacterkerning [\v!kerncharacters] [\c!factor=.125]
 
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index f3da9f3fb..a92e1a0b4 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 06/22/12 13:11:51
+-- merge date  : 06/25/12 14:10:27
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3