Add a notion of scopes (local to actions)

Closes #18