Fix some compile warnings related to casting