Merge pull request #153 from r-barnes/richard/binary_fix

Make binary search overflow safe