Finish basic reference code
Separate ReferenceEmitter