Bugfix: prevent overflow