fix %template warning and potential compile error