there may be an error in the calculation of dist in the C code (libdist.c). I've created a bunch of unit tests, all of which fail except one. I've created an issue about it issue #31