Add some checks to detect corrupt databases.