Some cleanups and command line fixes