Added type checking when getting the number of instances from command line arguments.