Removed extra sys.exits and fixed command line argument handling.