added openHistory() and closeHistory() and check for NaNs in outHistory()