Fix bug in OptimalCosineDistance, fixes #4