Support for units and other opt args, minor refactoring.