Reference search

Merge implementation of reference search into the master branch