Fixes a bug in capping a variable at Integer.MAX_VALUE