Added differentiation in template generation based on master/slave