added templates, improved build