added some basic command line options to instrumented script
made possible to specify a max number of grains