improved twoopt, but still seem to be broken