Final cleanup and error checks

A lot was added. Almost all errors are accounted for now and errors are
getting more useful.