Essays on firms and networks in the economy