many small fixes to the template addition