Fix "possible reference to past scope" warnings on 2.2