added command line parsing, headless mode