Added command stack to allow several contexts in commands

Fixes #462