Refactor template sub-blocks