Make sure scope isn't null. Fixes code analysis warning from #331.