casting and coalescing appropriately

Change-Id: I3b600d9935a632309116d8d3d1eb043ef3d64a36