Tidying up. No functional change.
Special handling for stubbing methods that create objects.