Database integrity check and database fixes.