Improve speed, simplify variable scope lookups