Fix main to handle arguments and deal with errors better.