[FIX] Fixed bugs with smart pointer