Fix template crashing problem with latin1