Merge "Fix potential overflows" am: a0c1eb865f
am: ef3542347c

Change-Id: I020bcf499ca455da44ff8eabcd867b44895eeb43