Serveral improvements on templates e mechanisms