Efficiency: fix handling of overflow
Merge pull request #592 from ndawe/master

Efficiency: fix handling of overflow