cleaned up lots of code in argument parsing and io/errors