Search the base path of the file containing a reference

Fixes #45