Variable scope corrected to properly cater for local scopes, also scope representation simplified'