Essays on Firm Heterogeneity with Empirical Applications in Economic History and Agricultural Economics