Fix various history related bugs