Add ScopeVisitor

Following discussion in #144