Fixes a problem with before and after scopes.