Add null checks when getting Pet and Owner objects.