\startenvironment headers

% TOC related
\setupcombinedlist[content][list={part,chapter,section}]

% How numbers are shown
\setuphead[part][placehead=yes, align=middle, sectionstarter=Part , sectionstopper=:]
\setuphead[chapter][sectionsegments=chapter, command=\MyChapter]
\setuphead[section][sectionsegments=chapter:section]
\setuphead[subsection][sectionsegments=chapter:section:subsection]

\define[2]\MyChapter
  {\framed[frame=off, width=max, align={flushleft,nothyphenated,verytolerant}, offset=0cm, toffset=1cm, boffset=1cm]{#1\\#2}}

\setuplabeltext [en] [chapter=Chapter~]

% een teller voor alles, prefix is chapter
\definecounter[lemmata][way=bychapter,prefixsegments=chapter]

\defineenumeration[definition][text=Definition]
\defineenumeration[remark][text=Remark]
\defineenumeration[example][text=Example]
\defineenumeration[lemma][text=Lemma]
\defineenumeration[proposition][text=Proposition]
\defineenumeration[theorem][text=Theorem]
\defineenumeration[corollary][text=Corollary]
\setupenumeration[definition,remark,example,lemma,proposition,theorem,corollary]
  [alternative=serried, width=fit, right=., counter=lemmata]

% Don't reset sections in new part
\definestructureresetset[default][1,0,1][1] % reset part, not chapter, section
\setuphead[sectionresetset=default]

\define\QED{\hfill$\square$}
\definestartstop[proof][before={{\it Proof. }}, after={\QED}]
\definestartstop[proofnoqed][before={{\it Proof. }}, after={}]


\stopenvironment