Completely redid scoping to use correct Lexical scoping.