cleanup templates code