Capital Flows, Credit Cycles and Macroprudential Policy