Improve shared_ptr and fix bug.