Fix history bugs