Added some Error-checking functionality.