completely changed scoping rules
slightly different behavior for interactive mode, plus bugfixes