Modified to take commandline switches from bash wrapper.