Replaced most of naked pointers by smart pointers
Updated to c++11 syntax