Fixed bug with weak_ptr