Fixed bug related to update_history() being called before the first trial.