Did some cleanup, and added a few more checks for various errors, using the FATAl_ERROR() macro. Might add better error handling later.