Refactor templating mechanism

can be removed, see above