WIP: added plumbing for handling commands
reverting from a breaking change in API
some reorganization