Fix for bug in the history saving mechanism.