Add some casts to fix compiler errors