Made database more resilient to error.