fixed binarySearchGeneric from infinite loop (added protection), fixed issue where all points have the same Y value. #222