Fix bug in variable purging

It did not notice direct scope assignments.