Rework chains, add templates, rename DOM to util