-pthread flag added. Using std::shared_ptr