Fix Py3 issue: reduce -> functools.reduce