Refactor lexical scope code into Scope.h