Rework all the command infrastructure to make it concurrent safe.

Separate command definition from command parsing state.