Got the reference thing pretty much working. Now investigating search bug.