This thesis consists of two essays on macroeconomics with heterogeneity. First essay quantifies the importance of aggregate fluctuations in microeconomic uncertainty for the firm dynamics over the business cycle in an economy with frictional financial markets. To begin, it documents facts on asymmetric response across age and size groups of firms in the U.S. to the changes in aggregate economic conditions. I argue that age rather than size is a relevant margin for the cyclical employment dynamics; in particular total employment of young firms varies 2.6 times more relative to the old firms. Then I propose a theory that, contrary to the existing studies, generates endogenously a link between firm's age and size and its ability to obtain financing, and induces an asymmetric response to shocks. A key element of my theory is a financial friction, originated from the firm's private information and long-term, efficient lending contract between a risk averse entrepreneur and financial intermediary, which manifests itself as a borrowing constraint. I argue that, for any given expected return on project, young firms are more constrained in borrowing and they grow out of the constraint as they age up to the optimal, unconstrained size. Next I establish that, for any given age, firm's financing increases in line with the average return on a project. In times of high idiosyncratic uncertainty the financial contract calls for tightening of the borrowing constraint transmitting the initial impulse into a decline in demand for production inputs and further, including general equilibrium effects, into an economic downturn. This mechanism affects disproportionally young firms. Not only are they more constrained in borrowing but also they start smaller due to a reduced level of initial financing. A quantitative version of the model accounts for the fall of the aggregate output, employment and investment, decline of credit to GDP ratio and asymmetric employment dynamics of different groups of firms observed in the US data in recessions. Second essay studies optimal taxation in an environment where heterogeneous households face uninsurable idiosyncratic risk. To do this, we formulate a Ramsey problem in a standard infinite horizon incomplete markets model. We solve numerically for the optimal path of proportional capital and labor income taxes, (possibly negative) lump-sum transfers, and government debt. The solution maximizes welfare along the transition between an initial steady state, calibrated to replicate key features of the US economy, and an endogenously determined final steady state. We find that in the optimal (utilitarian) policy: (i) capital income taxes are front-loaded hitting the imposed upper bound of 100 percent for 33 years before decreasing to 45 percent in the long-run; (ii) labor income taxes are reduced to less than half of their initial level, from 28 percent to about 13 percent in the long-run; and (iii) the government accumulates assets over time reducing the debt-to-output ratio from 63 percent to -17 percent in the long-run. Relative to keeping fiscal instruments at their initial levels, this leads to an average welfare gain equivalent to a permanent 4.9 percent increase in consumption. Even though non-distortive lump-sum taxes are available, the optimal plan has positive capital and labor taxes. Such taxes reduce the proportions of uncertain and unequal labor and capital incomes in total income, increasing welfare by providing insurance and redistribution. We are able to quantify these welfare effects. We also show that calculating the entire transition path (as opposed to considering steady states only) is quantitatively important. Implementing the policy that maximizes welfare in steady state leads to a welfare loss of 6.4 percent once transitory effects are accounted for.