Fix for repeated variables in instance head

Variables should only be brought into scope once! So remove any repeated
variables and only bind them once.