Added cast to bool for checking pointer validity of CountedPtr.