The origins of the division of labor in pre-industrial times