Replacing some raw pointers by smart pointers