[46344/46541 Fixed critical issues with template system