new way of applying templates and a few minor fixes throughout