Fix various compiler warnings about implicit casts