Cleanup and fix db error.