Favor local vars for highly used globals

Just a stab, let me know what you think :-)