analyser: added nested scopes, analyser refactoring