Added support for inheritance in template