Implemented proper history dumping to database.