[IMP] Improved code and template.