Minor improvement on output message error checking, ad a few comments.