Three Essays In Macroeconomics With Heterogeneous Agents