Scope some variables and cache some selectors