Added option parsing. Fixed issues revealed by passing down args.