Merge "Fix potential overflows" am: a0c1eb865f am: ef3542347c am: 2774f292b7
am: 3bcc22b176

Change-Id: I78bd28ee6abb4befea5c46c8d4be8799b88b227b