Fixed some validation and a cast error in the command framework.