Fixed compilation errors in templates