Fix history save and load