diff --git a/core/wiki/macros/tree.tid b/core/wiki/macros/tree.tid
index 8cba3339b..d47c1fbc4 100644
--- a/core/wiki/macros/tree.tid
+++ b/core/wiki/macros/tree.tid
@@ -1,53 +1,57 @@
title: $:/core/macros/tree
tags: $:/tags/Macro
-\define leaf-node(prefix)
+\define leaf-link(full-title, chunk)
+<$link to=<<__full-title__>>><$text text=<<__chunk__>>/>$link>
+\end
+
+\define leaf-node(prefix, chunk)
-<$list filter="""[[$prefix$$(chunk)$]is[shadow]] [[$prefix$$(chunk)$]is[tiddler]] +[removeprefix[$prefix$]] +[limit[1]]"""
-emptyMessage="""<$text text="$prefix$$(chunk)$"/>""">
-{{$:/core/images/file}} <$link to="""$prefix$$(chunk)$""">
-<$view field="title"/>
-$link>
+<$list filter="[<__prefix__>addsuffix<__chunk__>is[shadow]] [<__prefix__>addsuffix<__chunk__>is[tiddler]]" variable="full-title">
+<$list filter="[removeprefix<__prefix__>]" variable="chunk">
+{{$:/core/images/file}} <$macrocall $name="leaf-link" full-title=<> chunk=<>/>
+$list>
$list>
\end
-\define branch-node(prefix)
-<$reveal type="nomatch" text="" default="""$(chunk)$""">
-
-<$list filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]] +[limit[1]]""">
-<$reveal type="nomatch" stateTitle="""$:/state/tree/$prefix$$(chunk)$""" text="show">
-<$button setTitle="""$:/state/tree/$prefix$$(chunk)$""" setTo="show" class="tc-btn-invisible">{{$:/core/images/folder}} <$text text="""$(chunk)$"""/>$button>
+\define branch-node(prefix, chunk)
+
+<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}>
+<$reveal type="nomatch" stateTitle=<> text="show">
+<$button setTitle=<> setTo="show" class="tc-btn-invisible">
+{{$:/core/images/folder}} <$text text=<<__chunk__>>/>
+$button>
$reveal>
-<$reveal type="match" stateTitle="""$:/state/tree/$prefix$$(chunk)$""" text="show">
-<$button setTitle="""$:/state/tree/$prefix$$(chunk)$""" setTo="hide" class="tc-btn-invisible">{{$:/core/images/folder}} <$text text="""$(chunk)$"""/>$button>
+<$reveal type="match" stateTitle=<> text="show">
+<$button setTitle=<> setTo="hide" class="tc-btn-invisible">
+{{$:/core/images/folder}} <$text text=<<__chunk__>>/>
+$button>
$reveal>
-$list>
-<$list filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]] +[limit[1]]""">(<$count filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]]"""/>)
-<$reveal type="match" stateTitle="""$:/state/tree/$prefix$$(chunk)$""" text="show">
-<$macrocall $name="tree-node" prefix="""$prefix$$(chunk)$"""/>
+(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)
+<$reveal type="match" stateTitle=<> text="show">
+<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}}/>
$reveal>
-$list>
+$set>
-$reveal>
\end
\define tree-node(prefix)
-<$list filter="[all[shadows+tiddlers]removeprefix[$prefix$]splitbefore[/]sort[title]] +[!suffix[/]]" variable="chunk">
-<>
+<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]!suffix[/]]" variable="chunk">
+<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<>/>
$list>
-<$list filter="[all[shadows+tiddlers]removeprefix[$prefix$]splitbefore[/]sort[title]] +[suffix[/]]" variable="chunk">
-<>
+<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]suffix[/]]" variable="chunk">
+<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<>/>
$list>
\end
-\define tree(prefix)
+\define tree(prefix: "$:/")
-
<$text text="""$prefix$"""/>
+
<$text text=<<__prefix__>>/>
-<$macrocall $name="tree-node" prefix="""$prefix$"""/>
+<$macrocall $name="tree-node" prefix=<<__prefix__>>/>
\end