Fix bugs in logic of rank_hand_int