added support for max history, close #1588