db error handling tuning, fixes