Improve reference resolution.
Fix unit test harness.