Rearranged code and parse args.