Gross capital flows: dynamics and crises