fixed #18: Validation code for all commands.