Added some very basic error handling.