reduce boost::shared_ptr usage and fixed bugs