Cleaned up return types and NULL pointer comparison for CountedPtr.