Rewritten to argparse module, fixed some minor issues