Fix bug in generate_variable_instantiations