Fix variable scoping.