Fix treatment of shared variables
Better treatment of locals, shared, instance vars, and stack. Support nested local vars.