Credit frictions and default in macroeconomics