more fixes to setTemplate