Added explicit casts to make it 64-bit compatible (without any warnings).