Added history filtering and limiting.