Essays on Capital Flows and Macroprudential Regulation