Fixes #972. Implements Best_Match policy.
Fixes #975
Merge pull request #978 from emmanuel-keller/master

Bug fix and improvement