Re-scopes some variables to prevent garbage collection.