refactor to make all variables available to topscope class to facilitate easier profiling