Some code refactoring and changes to command usage.