Type changes and explicit casts to fix warnings in 64-bit builds