Fix bugs in the logic for the display of the history.