minimized memory usage for scripts at any depth