Add some casts for sanity before BagOStuff::add() calls

Change-Id: I6ecb609c88e4fc1ef614e94c551199bd610ca360
Merge "Add some casts for sanity before BagOStuff::add() calls"