added some flags and cmdline parsing