Restructures templates