Changes for code review

Addressed a number of concerns from the code review, chiefly
testing all of the error conditions in my c program