Use longs instead of ints

I noticed that the int conversion breaks when the result value is not representable. I just changed to longs everywhere; I'm not sure that there's ever a reason you'd want ints.