Fixed issue when reusing templates