Fix forward and backward history.