use templateDirectory(), big restructure