Fix same scopes are inspected multiple times

Fix issue #303.