Fixes deadlock when --help or invalid option is passed as command argume...

This fixes a deadlock when --help or invalid options are passed via command args. Also some general refactoring to make options easier to add in the future. Hope it's ok - thanks!