Fixed issues on template type changes