Add error trapping and more shell flags
Improve getopt behavior