Josh's C++ code for disambig. Copied from his Github.