Fix deprecation warnings. Use lambda in all scopes.