improved performance for dealing with NaN input data, original fix could not handle 0-d inputs
Merge remote-tracking branch 'upstream/master'