clean up command line option handling. remains a bit convoluted still