fix core dump when inserting a template in empty scheduler