added command line flags and started restructuring