Better handling of CLI options

See commits.