Add some additional casts to unsigned long to prevent warnings on 64-bit iPad