Improved partial name matcher

Fixes #1164