Title: Essays on credit contracts