Use Bash parameter substitution instead of tr to invert case
use argparse instead of optparse; clean up