Fix issues with scopes in sequences