Fixes lifetime/scope issues.