Merge "Minor type cast fixes for UBSan"