Clean up of template and mapping