Added some error reporting/handling