Merge "Fix NPE when casting" into pi-dev
am: 9115d371c3

Change-Id: I03443603d0d05b164031c439e6a897238cf56be0