From Habits to Social Structures