Capital Flows, Financial Intermediation and Macroprudential Policies