Do not rely on dicts.merge to change target
Also make dicts.merge actually not touch target. This is much cleaner
than modifying in place, especially since we assign the result of the
dicts.merge call to target most of the time anyway.
Patch by: Sverre Rabbelier
Use key().id_or_name() instead of key().name()
These two cases were introduced after the previous refactoring was
done and did not follow the new behavior.
Patch by: Sverre Rabbelier