Maintenance class for optimizing the database and correcting errors