added support for multiple templates and removed some old stuff