Added a large part of binary search infrastructure