Further Cleanup

Added in more error checking and cleaned up the readability of the file.