Fixed a memory leak in the history file