CommandFactory,refactoring: Add new class and use it.