added volatile and final where needed
added --help and --version arguments
and changed argument parsing while loop to a for loop