Utility to handle optional arguments and argument type checking.