Fix integer overflows am: c1aa8d1ad8 am: b8d0876ee3

Change-Id: If09377c4f609556527aff732aa4164e116140bbd