Make the database code more robust.