Add context stack to enable hierarchical switching between states