Added ability to specify a number of generations to run before terminating