Fixed preserving order when setting appropriate templates