reference_id -> reference_target
More complete ref bindings
Get rid of unused variables