Implemented some support for templates