Template extraction

Work-in-progress