I'm guessing both. Although more specifically an ingroup/outgroup thing. When belonging in the ingroup can have a huge effect on your class status, there's a huge incentive to play nice. And the longer one plays nice, the more they internalize the rules that protect the ingroup assholes.