More cpp template improvements