This thesis consists of eight self-contained essays on international trade and factor flows. In these essays, I address three topics that center around the following questions: What determines the boundaries of the firm in the global economy? What type of migration can countries expect to receive in the future, depending on their current migration profile? Can the labor market effects of protection explain individual attitudes towards international trade? In the first part of this thesis (Chapters 2, 3, and 4), I use firm-level data from Spain in order to investigate the boundaries of the firm in the global economy. Roughly one-third of world trade is intra-firm trade. Its distribution across countries and across sectors is not random, but...