Reference refactor

Seems ready, but good review needed.