Made some improvements on template builder