Aded templates to tree
Modified output functions (if instead of elif).