Fixes bugs in the database.