A few fixes for manage historical_data function