Fixed a bug for maxi and mini.

Bug reported by Kun Guo, thanks man!
Merge remote-tracking branch 'origin/master'