Change formula for calculating mid

old: mid = (upper + lower)/2
new: mid = (upper - lower)/2 + lower

Rough benchmarks with time indicate this is twice as fast