Add command factory and make editor state immutable.