Essays on corporate and sovereign default