Merge "Add casts to avoid errors due to narrowing" am: 4556cb9cb8
am: 515fb25ef7

Change-Id: Ic97d0e64efee960f87b2cb7581666b2af05873cd