Fix reduce functions.
Merge pull request #4227 from HassenRiahi/fix-reduce-functions

Fix reduce functions.