Add casts to make compiler happy