Fix handling of max hist cache on hist save