Added missing casts for Long.
Don't downcast when doing bit math.