Fix templates and small issues