template improvements

fix #87 #119